Package cdc.enums

Interface EnumType<V>

  • Type Parameters:
    V - The enum value type.
    All Superinterfaces:
    DagType<V>, ListType<V>
    All Known Subinterfaces:
    AbstractForestDynamicEnum.Support<V>, AbstractListDynamicEnum.Support<V>, DynamicEnumSupport<V>
    All Known Implementing Classes:
    AbstractDynamicEnumSupport, BooleanEnumType

    public interface EnumType<V>
    extends DagType<V>
    Interface describing an enumerated type.

    This can be used for standard enums but also for other kinds of enums.

    The semantic is more general than standard enums' semantic.
    Standard enums are flat. Here, values can have set inclusion semantic: An enum can be considered as a set of other enums.
    There is a partial or total order relation between values, depending on the implementation.

    Values can be created, removed, renamed, etc. at runtime, depending on implementation and enabled features.

    Author:
    Damien Carbonne
    • Method Detail

      • getChildNamed

        default V getChildNamed​(V value,
                                String name)
        Returns the child that has a name.
        Parameters:
        value - The value.
        name - The name.
        Returns:
        The child of [@code value} that has is named name or null.
      • hasChildNamed

        default boolean hasChildNamed​(V value,
                                      String name)
        Returns true when a value has a child that has a given name.
        Parameters:
        value - The value.
        name - The name.
        Returns:
        true when value has a child named name.
      • hasSiblingNamed

        default boolean hasSiblingNamed​(V value,
                                        String name)
        Returns true when a value has a sibling (different from itself) that has a given name.
        Parameters:
        value - The value.
        name - The sibling name.
        Returns:
        true when value has a sibling (other than value) that is named name.
      • getName

        String getName​(V value)
        Returns the name of a value.
        Parameters:
        value - The value.
        Returns:
        The name associated to value or null.
      • getQName

        String getQName​(V value)
        Returns the (preferred) qualified name (path) of a value.
        Parameters:
        value - The value.
        Returns:
        The qualified name (path) of value or null.
      • valueOf

        V valueOf​(String qname,
                  cdc.util.lang.FailureReaction reaction)
        Returns the value corresponding to a qualified name.
        Parameters:
        qname - The qualified name.
        reaction - The reaction to adopt when qname is unknown.
        Returns:
        The value corresponding to qname or null.
        Throws:
        cdc.util.lang.NotFoundException - When qname is unknown and reaction is FailureReaction.FAIL.
      • valueOf

        default V valueOf​(String qname)
        Returns the value associated to a qualified name (path).

        Notes
        Depending on implementation, several qualified names can correspond to the same value.

        Parameters:
        qname - The qualified name (path).
        Returns:
        The value associated to qname.
        Throws:
        cdc.util.lang.NotFoundException - When qname is unknown.
      • hasValue

        default boolean hasValue​(String qname)
        Returns true if a value with a qualified name is registered.
        Parameters:
        qname - The qualified name (path).
        Returns:
        true if a value with is registered under qname.
      • unknownQName

        static String unknownQName​(String qname)
      • createQNameComparator

        static <V> Comparator<V> createQNameComparator​(EnumType<V> enumType)
        Creates a qualified name comparator.
        Type Parameters:
        V - The enum value type.
        Parameters:
        enumType - The enum type.
        Returns:
        A comparator based on qualified names.