- java.lang.Object
-
- org.praxislive.core.Value.Type<T>
-
- Type Parameters:
T- value subclass
- Enclosing class:
- Value
public static class Value.Type<T extends Value> extends Object
The type of a Value. Only registered types can be used in PraxisCORE. Type maps to the class or superclass of a Value, and provides additional features such as simple name and conversion.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<T>asClass()The class that this Type maps to.Function<Value,Optional<T>>converter()A convertor function that can convert a value to this type.Optional<T>emptyValue()The empty value of this type, if this type supports empty values, as defined byValue.isEmpty().booleanequals(Object obj)static Optional<Value.Type<? extends Value>>fromName(String name)Return the Type with the given name, or an empty optional if unregistered.inthashCode()static List<Value.Type<?>>listAll()List of all registered Value Types.Stringname()Simple name for this Value type.static <T extends Value>
Value.Type<T>of(Class<T> cls)Return the Type mapping for the passed in Value class.StringtoString()
-
-
-
Method Detail
-
asClass
public Class<T> asClass()
The class that this Type maps to. May be a superclass of the actual class of a Value.- Returns:
- mapped class
-
name
public String name()
Simple name for this Value type.- Returns:
- type name
-
converter
public Function<Value,Optional<T>> converter()
A convertor function that can convert a value to this type. May cast, parse or otherwise convert the value. An empty Optional is returned if the value does not support conversion to the required type.- Returns:
- optional converted value
-
emptyValue
public Optional<T> emptyValue()
The empty value of this type, if this type supports empty values, as defined byValue.isEmpty().- Returns:
- optional of empty value
-
of
public static <T extends Value> Value.Type<T> of(Class<T> cls)
Return the Type mapping for the passed in Value class.- Type Parameters:
T- value type- Parameters:
cls- value class- Returns:
- Type
- Throws:
IllegalArgumentException- if the class is unregistered
-
fromName
public static Optional<Value.Type<? extends Value>> fromName(String name)
Return the Type with the given name, or an empty optional if unregistered.- Parameters:
name- type name- Returns:
- optional type or empty
-
listAll
public static List<Value.Type<?>> listAll()
List of all registered Value Types. The returned list is read-only.- Returns:
- list of types
-
-