T - the actual platform type used to store the serializable datapublic abstract class SerializableType<T> extends Object
A SerializableType constrains the range of possible values
through additional properties. This means that for each kind of
SerializableType there may be an arbitrary amount of different
sets of valid values, all being mapped to the same platform type.
For example, Integer and Double are both represented
as DecimalSerializableTypes and stored as BigDecimals,
but with different constraints.
| Modifier and Type | Method and Description |
|---|---|
boolean |
accepts(T serializedValue)
Returns whether this type's constraints accept the given value.
|
abstract T |
cast(Object value)
Casts an object to the type represented by this type.
|
abstract <S> T |
deserializeValue(S elem,
ValueSerializer<S,?> serializer)
Deserializes a config primitive from a serialized form.
|
abstract boolean |
equals(Object o)
Two serialized types are equal if and only if they are of the same kind
and both have the same constraints.
|
Class<? super T> |
getErasedPlatformType()
The (erased) Java platform type used to represent values of this type.
|
abstract Type |
getGenericPlatformType()
The generic Java platform type used to represent values of this type, with parameterized
type information preserved.
|
abstract int |
hashCode() |
boolean |
isAssignableFrom(SerializableType<?> type)
Determines if the data type represented by this
SerializableType
object is either the same as, or is a more general description of, the data
type represented by the specified type parameter. |
abstract <S> void |
serialize(TypeSerializer<S> serializer,
S target)
Serializes this type to a persistent format using the given
TypeSerializer. |
abstract <S> S |
serializeValue(T value,
ValueSerializer<S,?> serializer)
Serializes a config primitive to a serialized form.
|
TypeCheckResult<T> |
test(T serializedValue)
Tests the given value against this type's constraints.
|
abstract String |
toString() |
public Class<? super T> getErasedPlatformType()
public abstract Type getGenericPlatformType()
public abstract T cast(@Nonnull Object value)
This method does not check the value against this type's constraints. For parameterized types, this method may inspect the object and thus not run in constant time.
value - The value.ClassCastException - If the value is not of the platform type.public final boolean isAssignableFrom(SerializableType<?> type)
SerializableType
object is either the same as, or is a more general description of, the data
type represented by the specified type parameter.
Specifically, this checks whether every value assignable to type
can also be assigned to this SerializableType.
forall x, type.accepts(x) => this.accepts(x)
type - the type to be checkedtrue if properties of this type are assignable from values of type.public final boolean accepts(T serializedValue)
test(Object)public final TypeCheckResult<T> test(T serializedValue)
accepts(Object),
TypeCheckResultpublic abstract <S> void serialize(TypeSerializer<S> serializer, S target)
TypeSerializer.S - The type to serialize to.serializer - The type serializer to use.target - The place to which this type is serialized.TypeSerializerpublic abstract <S> S serializeValue(T value, ValueSerializer<S,?> serializer)
cast(Object) and additionally
satisfy this type's particular constraints.S - The type of the serialized form.value - The value to serialize.serializer - A ValueSerializer defining the serialized form.public abstract <S> T deserializeValue(S elem, ValueSerializer<S,?> serializer) throws ValueDeserializationException
S - The type of the serialized form.elem - The serialized form of the value.serializer - A ValueSerializer defining the serialized form.ValueDeserializationException - If a value cannot be deserialized.public abstract boolean equals(Object o)