public interface Serializer
Tto an output stream and read the object back in from an input stream.
|Modifier and Type||Method and Description|
Indicates whether this Serializer is capable of serializing to the given
Returns the class for the given type identifier.
Deserializes the first object read from the given
Serialize the given
Returns the type identifier for the given class.
<T> SerializedObject<T> serialize(@Nullable Object object, @Nonnull Class<T> expectedRepresentation)
objectinto a Serialized Object containing the given
canSerializeTo(Class)to detect whether the
expectedRepresentationis supported by this serializer.
T- The expected data type representing the serialized object
object- The object to serialize
expectedRepresentation- The expected data type representing the serialized object
true, this does *not* guarantee that the serialization and (optional) conversion will also succeed when executed. For example, when a serializer produces a
bytecontaining JSON, trying to convert to a Dom4J Document will fail, even though this serializer has a converter to convert
byteto Dom4J instances.
T- The type of data a Serialized Object should contain
expectedRepresentation- The type of data a Serialized Object should contain
expectedRepresentationis supported, otherwise
<S,T> T deserialize(@Nonnull SerializedObject<S> serializedObject)
bytesare not consumed from the array or modified in any way. The resulting object instance is cast to the expected type.
S- The data type of the serialized object
T- The expected deserialized type
serializedObject- the instance describing the type of object and the bytes providing the serialized data
ClassCastException- if the first object in the stream is not an instance of <T>.
Class classForType(@Nonnull SerializedType type)
typeis 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
UnknownSerializedTypeinstance which proides access to the raw underlying data.
type- The type identifier of the object
SerializedType typeForClass(@Nullable Class type)
type- Class representing the type of the serializable Object.
Copyright © 2010–2023. All rights reserved.