@Singleton
public class ProtobufferCodec
extends java.lang.Object
implements io.micronaut.http.codec.MediaTypeCodec
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROTOBUFFER_ENCODED
Protobuffer encoded data: application/x-protobuf.
|
static io.micronaut.http.MediaType |
PROTOBUFFER_ENCODED_TYPE
Protobuffer encoded data: application/x-protobuf.
|
static java.lang.String |
X_PROTOBUF_MESSAGE_HEADER
This Header is to say the fully qualified name of the message builder to use.
|
| Constructor and Description |
|---|
ProtobufferCodec(com.google.protobuf.ExtensionRegistry extensionRegistry) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
decode(io.micronaut.core.type.Argument<T> type,
byte[] bytes) |
<T> T |
decode(io.micronaut.core.type.Argument<T> type,
io.micronaut.core.io.buffer.ByteBuffer<?> buffer) |
<T> T |
decode(io.micronaut.core.type.Argument<T> type,
java.io.InputStream inputStream) |
<T> byte[] |
encode(T object) |
<T> io.micronaut.core.io.buffer.ByteBuffer |
encode(T object,
io.micronaut.core.io.buffer.ByteBufferFactory allocator) |
<T> void |
encode(T object,
java.io.OutputStream outputStream) |
com.google.protobuf.ExtensionRegistry |
getExtensionRegistry() |
java.util.Collection<io.micronaut.http.MediaType> |
getMediaTypes() |
java.util.Optional<com.google.protobuf.Message.Builder> |
getMessageBuilder(java.lang.Class<? extends com.google.protobuf.Message> clazz)
Create a new
Message.Builder instance for the given class. |
boolean |
supportsType(java.lang.Class<?> type) |
public static final java.lang.String PROTOBUFFER_ENCODED
public static final java.lang.String X_PROTOBUF_MESSAGE_HEADER
public static final io.micronaut.http.MediaType PROTOBUFFER_ENCODED_TYPE
public ProtobufferCodec(com.google.protobuf.ExtensionRegistry extensionRegistry)
public boolean supportsType(java.lang.Class<?> type)
supportsType in interface io.micronaut.http.codec.MediaTypeCodecpublic java.util.Collection<io.micronaut.http.MediaType> getMediaTypes()
getMediaTypes in interface io.micronaut.http.codec.MediaTypeCodecpublic <T> T decode(io.micronaut.core.type.Argument<T> type,
java.io.InputStream inputStream)
throws io.micronaut.http.codec.CodecException
decode in interface io.micronaut.http.codec.MediaTypeCodecio.micronaut.http.codec.CodecExceptionpublic <T> T decode(io.micronaut.core.type.Argument<T> type,
io.micronaut.core.io.buffer.ByteBuffer<?> buffer)
throws io.micronaut.http.codec.CodecException
decode in interface io.micronaut.http.codec.MediaTypeCodecio.micronaut.http.codec.CodecExceptionpublic <T> T decode(io.micronaut.core.type.Argument<T> type,
byte[] bytes)
throws io.micronaut.http.codec.CodecException
decode in interface io.micronaut.http.codec.MediaTypeCodecio.micronaut.http.codec.CodecExceptionpublic <T> void encode(T object,
java.io.OutputStream outputStream)
throws io.micronaut.http.codec.CodecException
encode in interface io.micronaut.http.codec.MediaTypeCodecio.micronaut.http.codec.CodecExceptionpublic <T> byte[] encode(T object)
throws io.micronaut.http.codec.CodecException
encode in interface io.micronaut.http.codec.MediaTypeCodecio.micronaut.http.codec.CodecExceptionpublic <T> io.micronaut.core.io.buffer.ByteBuffer encode(T object,
io.micronaut.core.io.buffer.ByteBufferFactory allocator)
throws io.micronaut.http.codec.CodecException
encode in interface io.micronaut.http.codec.MediaTypeCodecio.micronaut.http.codec.CodecExceptionpublic com.google.protobuf.ExtensionRegistry getExtensionRegistry()
public java.util.Optional<com.google.protobuf.Message.Builder> getMessageBuilder(java.lang.Class<? extends com.google.protobuf.Message> clazz)
Message.Builder instance for the given class.
This method uses a ConcurrentHashMap for caching method lookups.