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 ClassesModifier and TypeClassDescriptionstatic interfaceAbstractForestDynamicEnum.Creator<V extends ForestDynamicEnum<V>>Interface used to create new instances of a dynamic enum.static interfacestatic interfaceAbstractForestDynamicEnum.Support<V extends ForestDynamicEnum<V>>Support interface describing standard methods expected for a dynamic enum. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charCharacter used to separate local names in paths.Fields inherited from interface cdc.enums.DynamicEnum
NAME_COMPARATOR, QNAME_COMPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanfinal StringgetName()final Vfinal StringgetQName()inthashCode()protected final voidprotected final voidprotected static <V extends AbstractForestDynamicEnum<V>>
AbstractForestDynamicEnum.Support<V>support(Class<V> cls, AbstractForestDynamicEnum.Creator<V> creator, DagFeature... features) 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) 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.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface cdc.enums.ForestDynamicEnum
hasChildNamed, isOverOrEqual, isStrictlyOver
-
Field Details
-
children
-
SEPARATOR
public static final char SEPARATORCharacter used to separate local names in paths.- See Also:
-
-
Constructor Details
-
AbstractForestDynamicEnum
-
-
Method Details
-
setParent
-
getParent
- Specified by:
getParentin interfaceForestDynamicEnum<V extends AbstractForestDynamicEnum<V>>- Returns:
- The parent of this enumeration value.
-
getChildren
- Specified by:
getChildrenin interfaceForestDynamicEnum<V extends AbstractForestDynamicEnum<V>>- Returns:
- The children of this enumeration value.
-
setName
-
getName
- Specified by:
getNamein interfaceDynamicEnum- Returns:
- The local name.
-
getQName
- Specified by:
getQNamein interfaceDynamicEnum- Returns:
- The qualified name (path).
-
toString
-
hashCode
public int hashCode() -
equals
-
compareTo
- 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)
-