T - The runtime type of the underlying finite string value.public final class EnumConfigType<T> extends ConfigType<T,String,EnumSerializableType>
ConfigType for a finite set of values. These are often the constants of a Java enum,
but are represented as strings here in order to support serialization and deserialization.deserializer, serializer| Constructor and Description |
|---|
EnumConfigType(EnumSerializableType serializedType,
Class<T> runtimeType,
Function<String,T> f,
Function<T,String> f0) |
| Modifier and Type | Method and Description |
|---|---|
EnumConfigType<T> |
constrain(ConstraintAnnotationProcessor<Annotation> processor,
Annotation annotation,
AnnotatedElement annotated)
Applies the constraints defined by the given constraint annotation.
|
<U> EnumConfigType<U> |
derive(Class<? super U> runtimeType,
Function<T,U> partialDeserializer,
Function<U,T> partialSerializer)
Derive a
ConfigType from this type object. |
EnumConfigType<T> |
withType(EnumSerializableType newSpec)
Replace the current serialized type used for specification with the given serialized type.
|
EnumConfigType<T> |
withValues(Set<? extends T> values)
Returns a new
EnumConfigType that represents the given set of values. |
EnumConfigType<T> |
withValues(T... values)
Returns a new
EnumConfigType that represents the given set of values. |
getRuntimeType, getSerializedType, toPlatformType, toRuntimeType, toSerializedType, toStringpublic <U> EnumConfigType<U> derive(Class<? super U> runtimeType, Function<T,U> partialDeserializer, Function<U,T> partialSerializer)
ConfigTypeConfigType 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)).
derive in class ConfigType<T,String,EnumSerializableType>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 EnumConfigType<T> withType(EnumSerializableType newSpec)
ConfigTypewithType in class ConfigType<T,String,EnumSerializableType>newSpec - The new type specification.SerializableType.isAssignableFrom(SerializableType)public EnumConfigType<T> constrain(ConstraintAnnotationProcessor<Annotation> processor, Annotation annotation, AnnotatedElement annotated)
ConfigTypeconstrain in class ConfigType<T,String,EnumSerializableType>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.public EnumConfigType<T> withValues(Set<? extends T> values)
EnumConfigType that represents the given set of values. The values
are converted to the serialized type String before being stored as the new type's constraints.values - A Set of values of the runtime type whose serialized forms are the acceptable values.withValues(Object[])@SafeVarargs public final EnumConfigType<T> withValues(T... values)
EnumConfigType that represents the given set of values. The values
are converted to the serialized type String before being stored as the new type's constraints.values - A Set of values of the runtime type whose serialized forms are the acceptable values.withValues(Set)