BaseType - The base type that all other types will derive from.public abstract static class VersionedSerializer.MultiType<BaseType> extends VersionedSerializer<BaseType>
class BaseType { ... }
class SubType1 extends BaseType {
static class SubType1Builder implements ObjectBuilder { ... }
static class SubType1Serializer extends VersionedSerializer.WithBuilder { ... }
}
class SubType11 extends SubType1 {
static class SubType11Builder implements ObjectBuilder { ... }
static class SubType11Serializer extends VersionedSerializer.WithBuilder { ... }
}
class SubType2 extends BaseType {
static class SubType2Builder implements ObjectBuilder { ... }
static class SubType2Serializer extends VersionedSerializer.WithBuilder { ... }
}
class BaseTypeSerializer extends VersionedSerializer.MultiType { | Modifier and Type | Class and Description |
|---|---|
protected class |
VersionedSerializer.MultiType.Builder |
VersionedSerializer.Direct<TargetType>, VersionedSerializer.FormatVersion<TargetType,ReaderType>, VersionedSerializer.MultiType<BaseType>, VersionedSerializer.StreamReader<ReaderType>, VersionedSerializer.StreamWriter<TargetType>, VersionedSerializer.WithBuilder<TargetType,ReaderType extends ObjectBuilder<TargetType>>| Constructor and Description |
|---|
MultiType()
Creates a new instance of the MultiType class.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
declareSerializers(VersionedSerializer.MultiType.Builder builder)
When implemented in a derived class, this method will declare all supported serializers of subtypes of BaseType
by using the serializer() method.
|
BaseType |
deserialize(ArrayView data)
Deserializes data from the given ArrayView and creates a new object with the result.
|
BaseType |
deserialize(java.io.InputStream stream)
Deserializes data from the given InputStream into an object of type BaseType.
|
void |
serialize(java.io.OutputStream stream,
BaseType o)
Serializes the given object to the given OutputStream.
|
serialize, serializeprotected abstract void declareSerializers(VersionedSerializer.MultiType.Builder builder)
builder - A MultiType.Builder that can be used to declare serializers.public void serialize(java.io.OutputStream stream,
BaseType o)
throws java.io.IOException
VersionedSerializerserialize in class VersionedSerializer<BaseType>stream - The OutputStream to serialize to.o - The object to serialize.java.io.IOException - If an IO Exception occurred.public BaseType deserialize(java.io.InputStream stream) throws java.io.IOException
stream - The InputStream to deserialize from.java.io.IOException - If an IO Exception occurred.public BaseType deserialize(ArrayView data) throws java.io.IOException
data - The ArrayView to deserialize from.java.io.IOException - If an IO Exception occurred.