Class Value.Type<T extends Value>

  • 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 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 by Value.isEmpty().
        Returns:
        optional of empty value
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • of

        public static <T extends ValueValue.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