Class ProtobufMapper
java.lang.Object
io.micronaut.serde.protobuf.ProtobufMapper
- All Implemented Interfaces:
io.micronaut.json.JsonMapper, ObjectMapper
@Singleton
@Bean(typed=ProtobufMapper.class)
public final class ProtobufMapper
extends Object
implements ObjectMapper
An
ObjectMapper that reads and writes the Protocol Buffers binary wire format.
Unlike the JSON and BSON mappers, this one is not self-describing: a payload can only be read
into a concrete type whose properties carry
ProtoField numbers. Reading into
JsonNode or Object is therefore not supported.
This is a prototype. Its bean is exposed only as ProtobufMapper, so it cannot be
selected as the application's JSON mapper; inject it by its concrete type.
- Since:
- 3.2
-
Nested Class Summary
Nested classes/interfaces inherited from interface ObjectMapper
ObjectMapper.CloseableObjectMapper -
Constructor Summary
ConstructorsConstructorDescriptionProtobufMapper(SerdeRegistry registry, @Nullable SerdeConfiguration serdeConfiguration) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.json.JsonMappercloneWithViewClass(Class<?> viewClass) org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode> createReactiveParser(Consumer<org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray) Returns theSerdeRegistryused by this object mapper, if possible.io.micronaut.json.JsonStreamConfig<T> @Nullable TreadValue(byte[] byteArray, io.micronaut.core.type.Argument<T> type) <T> @Nullable TreadValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) <T> @Nullable TreadValueFromTree(io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) <T> voidwriteValue(OutputStream outputStream, io.micronaut.core.type.Argument<T> type, @Nullable T object) voidwriteValue(OutputStream outputStream, @Nullable Object object) <T> byte[]writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) byte[]writeValueAsBytes(@Nullable Object object) <T> io.micronaut.json.tree.JsonNodewriteValueToTree(io.micronaut.core.type.Argument<T> type, @Nullable T value) io.micronaut.json.tree.JsonNodewriteValueToTree(@Nullable Object value) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.json.JsonMapper
createSpecific, detectFeatures, readValue, readValue, readValue, readValue, readValue, readValue, readValueFromTree, updateValueFromTree, writeValueAsString, writeValueAsString, writeValueAsStringMethods inherited from interface ObjectMapper
cloneWithConfiguration, cloneWithConfiguration, cloneWithFeatures, updateValue, updateValue, updateValue, updateValue, updateValue
-
Constructor Details
-
ProtobufMapper
@Inject public ProtobufMapper(SerdeRegistry registry, @Nullable SerdeConfiguration serdeConfiguration) Default constructor.- Parameters:
registry- The serde registryserdeConfiguration- The serde configuration, if one is available
-
-
Method Details
-
getSerdeRegistry
Description copied from interface:ObjectMapperReturns theSerdeRegistryused by this object mapper, if possible.- Specified by:
getSerdeRegistryin interfaceObjectMapper- Returns:
- The serde registry
-
cloneWithViewClass
- Specified by:
cloneWithViewClassin interfaceio.micronaut.json.JsonMapper
-
getStreamConfig
public io.micronaut.json.JsonStreamConfig getStreamConfig()- Specified by:
getStreamConfigin interfaceio.micronaut.json.JsonMapper
-
writeValueAsBytes
public <T> byte[] writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException - Specified by:
writeValueAsBytesin interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValueAsBytes
- Specified by:
writeValueAsBytesin interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValue
public <T> void writeValue(OutputStream outputStream, io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException - Specified by:
writeValuein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValue
- Specified by:
writeValuein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
readValue
public <T> @Nullable T readValue(byte[] byteArray, io.micronaut.core.type.Argument<T> type) throws IOException - Specified by:
readValuein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
readValue
public <T> @Nullable T readValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) throws IOException - Specified by:
readValuein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValueToTree
public <T> io.micronaut.json.tree.JsonNode writeValueToTree(io.micronaut.core.type.Argument<T> type, @Nullable T value) throws IOException - Specified by:
writeValueToTreein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValueToTree
- Specified by:
writeValueToTreein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
readValueFromTree
public <T> @Nullable T readValueFromTree(io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) throws IOException - Specified by:
readValueFromTreein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
createReactiveParser
public org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode> createReactiveParser(Consumer<org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray) - Specified by:
createReactiveParserin interfaceio.micronaut.json.JsonMapper
-