Package cdc.enums
Class AbstractForestDynamicEnum<V extends AbstractForestDynamicEnum<V>>
- java.lang.Object
-
- cdc.enums.AbstractForestDynamicEnum<V>
-
- Type Parameters:
V- The dynamic enum concrete type.
- All Implemented Interfaces:
DynamicEnum,ForestDynamicEnum<V>,Comparable<V>
public abstract class AbstractForestDynamicEnum<V extends AbstractForestDynamicEnum<V>> extends Object implements ForestDynamicEnum<V>, Comparable<V>
Dynamic enumeration of values organized as a forest (several trees).Each value has a unique qualified name.
This implementation supports these features:DagFeature.LOCKINGDagFeature.CREATIONtill locked.DagFeature.REMOVALif allowed at creation time and till locked.DagFeature.CONTENT_CHANGEif allowed at creation time and till locked.DagFeature.REPARENTINGif allowed at creation time and till locked.
A typical implementation should look like this:
public final class Foo extends AbstractForestDynamicEnum<Foo> { public static final Support<Foo> SUPPORT = support(Foo.class, Foo::new, Feature.RENAMING, ...); protected Foo(Foo parent, String value) { super(parent, value); } }- Author:
- Damien Carbonne
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractForestDynamicEnum.Creator<V extends ForestDynamicEnum<V>>Interface used to create new instances of a dynamic enum.static interfaceAbstractForestDynamicEnum.Modifier<V extends ForestDynamicEnum<V>>static interfaceAbstractForestDynamicEnum.Support<V extends ForestDynamicEnum<V>>Support interface describing standard methods expected for a dynamic enum.
-
Field Summary
Fields Modifier and Type Field Description (package private) List<V>childrenstatic charSEPARATORCharacter used to separate local names in paths.-
Fields inherited from interface cdc.enums.DynamicEnum
NAME_COMPARATOR, QNAME_COMPARATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractForestDynamicEnum(V parent, String name)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface cdc.enums.ForestDynamicEnum
hasChildNamed, isOverOrEqual, isStrictlyOver
-
-
-
-
Field Detail
-
children
final List<V extends AbstractForestDynamicEnum<V>> children
-
SEPARATOR
public static final char SEPARATOR
Character used to separate local names in paths.- See Also:
- Constant Field Values
-
-
Method Detail
-
setParent
protected final void setParent(V parent)
-
getParent
public final V getParent()
- Specified by:
getParentin interfaceForestDynamicEnum<V extends AbstractForestDynamicEnum<V>>- Returns:
- The parent of this enumeration value.
-
getChildren
public final List<V> getChildren()
- Specified by:
getChildrenin interfaceForestDynamicEnum<V extends AbstractForestDynamicEnum<V>>- Returns:
- The children of this enumeration value.
-
setName
protected final void setName(String name)
-
getName
public final String getName()
- Specified by:
getNamein interfaceDynamicEnum- Returns:
- The local name.
-
getQName
public final String getQName()
- Specified by:
getQNamein interfaceDynamicEnum- Returns:
- The qualified name (path).
-
compareTo
public int compareTo(V o)
- Specified by:
compareToin interfaceComparable<V extends AbstractForestDynamicEnum<V>>
-
support
public static <V extends ForestDynamicEnum<V>> AbstractForestDynamicEnum.Support<V> support(Class<V> cls, Predicate<String> nameValidator, AbstractForestDynamicEnum.Creator<V> creator, AbstractForestDynamicEnum.Modifier<V> modifier, DagFeature... features)
-
support
protected static <V extends AbstractForestDynamicEnum<V>> AbstractForestDynamicEnum.Support<V> support(Class<V> cls, Predicate<String> nameValidator, AbstractForestDynamicEnum.Creator<V> creator, DagFeature... features)
Creates a support instance.- Type Parameters:
V- The dynamic enum type.- Parameters:
cls- The dynamic enum class.nameValidator- The predicate to check names validity.creator- The dynamic enum factoryfeatures- The features to enable.- Returns:
- A new instance of Support for
<E>
-
support
protected static <V extends AbstractForestDynamicEnum<V>> AbstractForestDynamicEnum.Support<V> support(Class<V> cls, AbstractForestDynamicEnum.Creator<V> creator, DagFeature... features)
-
-