public final class GrpcMetaDataAwareSerializer extends Object implements Serializer
| Constructor and Description |
|---|
GrpcMetaDataAwareSerializer(Serializer delegate)
Constructs a
GrpcMetaDataAwareSerializer, using the given delegate to delegate serialization to |
| Modifier and Type | Method and Description |
|---|---|
<T> boolean |
canSerializeTo(Class<T> expectedRepresentation)
Indicates whether this Serializer is capable of serializing to the given
expectedRepresentation. |
Class |
classForType(SerializedType type)
Returns the class for the given type identifier.
|
<S,T> T |
deserialize(SerializedObject<S> serializedObject)
Deserializes the first object read from the given
bytes. |
boolean |
equals(Object o) |
Converter |
getConverter()
Returns the
Converter used by this Serializer to convert between serialized representations. |
int |
hashCode() |
<T> SerializedObject<T> |
serialize(Object object,
Class<T> expectedRepresentation)
Serialize the given
object into a Serialized Object containing the given
expectedRepresentation. |
SerializedType |
typeForClass(Class type)
Returns the type identifier for the given class.
|
public GrpcMetaDataAwareSerializer(Serializer delegate)
GrpcMetaDataAwareSerializer, using the given delegate to delegate serialization todelegate - the Serializer to delegate serialization topublic <T> SerializedObject<T> serialize(Object object, @Nonnull Class<T> expectedRepresentation)
Serializerobject into a Serialized Object containing the given
expectedRepresentation.
Use Serializer.canSerializeTo(Class) to detect whether the expectedRepresentation is supported by
this serializer.serialize in interface SerializerT - The expected data type representing the serialized objectobject - The object to serializeexpectedRepresentation - The expected data type representing the serialized objectpublic <T> boolean canSerializeTo(@Nonnull Class<T> expectedRepresentation)
SerializerexpectedRepresentation.
When true, this does *not* guarantee that the serialization and (optional) conversion will also
succeed when executed. For example, when a serializer produces a byte[] containing JSON, trying to
convert to a Dom4J Document will fail, even though this serializer has a converter to convert
byte[]
to Dom4J instances.canSerializeTo in interface SerializerT - The type of data a Serialized Object should containexpectedRepresentation - The type of data a Serialized Object should containtrue if the expectedRepresentation is supported, otherwise false.public <S,T> T deserialize(@Nonnull SerializedObject<S> serializedObject)
Serializerbytes. The bytes are not consumed
from the array or modified in any way. The resulting object instance is cast to the expected type.deserialize in interface SerializerS - The data type of the serialized objectT - The expected deserialized typeserializedObject - the instance describing the type of object and the bytes providing the serialized datapublic Class classForType(@Nonnull SerializedType type)
Serializertype is an instance of the returned Class.
If a class cannot be resolved (i.e. because the class is not available on this JVM's classpath) this method
returns an UnknownSerializedType instance which proides access to the raw underlying data.classForType in interface Serializertype - The type identifier of the objectpublic SerializedType typeForClass(Class type)
SerializerSerializer.serialize(Object, Class).typeForClass in interface Serializertype - Class representing the type of the serializable Object.public Converter getConverter()
SerializerConverter used by this Serializer to convert between serialized representations. Generally,
this Converter depends on the type of data the serializer serializes to.getConverter in interface SerializerCopyright © 2010–2023. All rights reserved.