R - the runtime type used by the client applicationS - the serialized type used by config trees and serializersT - the representation of the serialized typepublic abstract class ConfigType<R,S,T extends SerializableType<S>> extends Object
ConfigType contains serializable information describing
a data type as well as the information necessary to convert a serialized
value of that type to a friendlier runtime type.| Modifier and Type | Field and Description |
|---|---|
protected Function<S,R> |
deserializer |
protected Function<R,S> |
serializer |
| Modifier and Type | Method and Description |
|---|---|
abstract ConfigType<R,S,T> |
constrain(ConstraintAnnotationProcessor<Annotation> processor,
Annotation annotation,
AnnotatedElement annotated)
Applies the constraints defined by the given constraint annotation.
|
abstract <U> ConfigType<U,S,T> |
derive(Class<? super U> runtimeType,
Function<R,U> partialDeserializer,
Function<U,R> partialSerializer)
Derive a
ConfigType from this type object. |
Class<R> |
getRuntimeType()
The runtime type of values.
|
T |
getSerializedType()
The underlying serialized type of values.
|
S |
toPlatformType(R runtimeValue)
Converts directly a runtime value from a client application to an equivalent value in the serializable
platform type.
|
R |
toRuntimeType(S serializedValue)
Converts a serialized value to this
ConfigType's runtime type. |
S |
toSerializedType(R runtimeValue)
Converts a runtime value from a client application to this
ConfigType's
serialized type. |
String |
toString() |
abstract ConfigType<R,S,T> |
withType(T newSpec)
Replace the current serialized type used for specification with the given serialized type.
|
public abstract <U> ConfigType<U,S,T> derive(Class<? super U> runtimeType, Function<R,U> partialDeserializer, Function<U,R> partialSerializer)
ConfigType from this type object.
The new ConfigType will have the same serialized type (with the same constraints),
but a different runtime type. Values will be converted between the two
types using composed functions: toSerializedType(x) = this.toSerializedType(partialSerializer(x))
and toRuntimeType(y) = partialDeserializer(this.toRuntimeType(y)).
U - the runtime type of the new ConfigTyperuntimeType - a class object representing the runtime type of the new ConfigTypepartialDeserializer - a partial deserialization functionpartialSerializer - a partial serialization functionConfigType with the given runtimeTypepublic abstract ConfigType<R,S,T> withType(T newSpec)
newSpec - The new type specification.SerializableType.isAssignableFrom(SerializableType)public S toSerializedType(R runtimeValue) throws FiberConversionException
ConfigType's
serialized type.runtimeValue - the value to convert to serializable formFiberConversionException - if the value does not fit this converter's constraintSerializableType.accepts(Object),
toPlatformType(Object)public S toPlatformType(R runtimeValue)
runtimeValue - the value to convert to serializable formSerializableType.getGenericPlatformType(),
toSerializedType(Object)public R toRuntimeType(S serializedValue) throws FiberConversionException
ConfigType's runtime type.serializedValue - the value to convert to runtime formFiberConversionException - if the serialized value does not fit this converter's constraintspublic T getSerializedType()
public abstract ConfigType<R,S,T> constrain(ConstraintAnnotationProcessor<Annotation> processor, Annotation annotation, AnnotatedElement annotated)
processor - The processor for constraints of this type.annotation - The annotation from which to extract constraints.annotated - The annotated element. For example, a field in a POJO.