public final class ProtobufSerializationProvider extends java.lang.Object implements SerializationProvider
SerializationProvider
for serializing/deserializing
protocol buffer objects.
Note: This implementation assumes byte streams represent a single message. This implementation currently uses
writeTo/parseFrom
and not writeDelimitedTo/parseDelimitedFrom
to serialize/deserialize messages.
It cannot be used to process a stream of delimited messages on a single Buffer.Constructor and Description |
---|
ProtobufSerializationProvider() |
ProtobufSerializationProvider(java.util.function.Function<java.lang.Class<?>,com.google.protobuf.Parser<?>> parserForClass) |
Modifier and Type | Method and Description |
---|---|
<T> StreamingDeserializer<T> |
getDeserializer(java.lang.Class<T> classToDeSerialize)
Provide a
StreamingDeserializer instance that can deserialize instances of T . |
<T> StreamingDeserializer<T> |
getDeserializer(TypeHolder<T> typeToDeserialize)
Provide a
StreamingDeserializer instance that can deserialize instances of T . |
<T> StreamingSerializer |
getSerializer(java.lang.Class<T> classToSerialize)
Provide a
StreamingSerializer instance that can serialize instances of T . |
<T> StreamingSerializer |
getSerializer(TypeHolder<T> typeToSerialize)
Provide a
StreamingSerializer instance that can serialize instances of T . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
serialize
public ProtobufSerializationProvider()
public ProtobufSerializationProvider(java.util.function.Function<java.lang.Class<?>,com.google.protobuf.Parser<?>> parserForClass)
public <T> StreamingSerializer getSerializer(java.lang.Class<T> classToSerialize)
SerializationProvider
StreamingSerializer
instance that can serialize instances of T
.getSerializer
in interface SerializationProvider
T
- The data type to serialize.classToSerialize
- The class for T
, the object to be serialized.StreamingSerializer
that can serialize instances of T
.public <T> StreamingSerializer getSerializer(TypeHolder<T> typeToSerialize)
SerializationProvider
StreamingSerializer
instance that can serialize instances of T
.getSerializer
in interface SerializationProvider
T
- The data type to serialize.typeToSerialize
- TypeHolder
holding the ParameterizedType
to be serialized.StreamingSerializer
that can serialize instances of T
.public <T> StreamingDeserializer<T> getDeserializer(java.lang.Class<T> classToDeSerialize)
SerializationProvider
StreamingDeserializer
instance that can deserialize instances of T
.getDeserializer
in interface SerializationProvider
T
- The data type to deserialize.classToDeSerialize
- The class for T
, the object to be deserialized.StreamingDeserializer
that can deserialize instances of T
.public <T> StreamingDeserializer<T> getDeserializer(TypeHolder<T> typeToDeserialize)
SerializationProvider
StreamingDeserializer
instance that can deserialize instances of T
.getDeserializer
in interface SerializationProvider
T
- The data type to deserialize.typeToDeserialize
- TypeHolder
holding the ParameterizedType
to be deserialized.StreamingDeserializer
that can deserialize instances of T
.