Package cdc.enums
Interface EnumType<V>
-
- Type Parameters:
V- The enum value type.
- 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 Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <V> Comparator<V>createQNameComparator(EnumType<V> enumType)Creates a qualified name comparator.default VgetChildNamed(V value, String name)Returns the child that has a name.StringgetName(V value)Returns the name of a value.StringgetQName(V value)Returns the (preferred) qualified name (path) of a value.default booleanhasChildNamed(V value, String name)Returnstruewhen a value has a child that has a given name.default booleanhasSiblingNamed(V value, String name)Returnstruewhen a value has a sibling (different from itself) that has a given name.default booleanhasValue(String qname)Returnstrueif a value with a qualified name is registered.static StringunknownQName(String qname)default VvalueOf(String qname)Returns the value associated to a qualified name (path).VvalueOf(String qname, cdc.util.lang.FailureReaction reaction)Returns the value corresponding to a qualified name.-
Methods inherited from interface cdc.enums.DagType
getChildren, getParents, getRoots, isOverOrEqual, isRoot, isStrictlyOver, isStrictlyUnder, isUnderOrEqual
-
Methods inherited from interface cdc.enums.ListType
addEventHandler, areEqual, getValueClass, getValues, isLocked, isSupported, isUsable, isValid, removeEventHandler
-
-
-
-
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
nameornull.
-
hasChildNamed
default boolean hasChildNamed(V value, String name)
Returnstruewhen a value has a child that has a given name.- Parameters:
value- The value.name- The name.- Returns:
truewhenvaluehas a child namedname.
-
hasSiblingNamed
default boolean hasSiblingNamed(V value, String name)
Returnstruewhen a value has a sibling (different from itself) that has a given name.- Parameters:
value- The value.name- The sibling name.- Returns:
truewhenvaluehas a sibling (other thanvalue) that is namedname.
-
getName
String getName(V value)
Returns the name of a value.- Parameters:
value- The value.- Returns:
- The name associated to
valueornull.
-
getQName
String getQName(V value)
Returns the (preferred) qualified name (path) of a value.- Parameters:
value- The value.- Returns:
- The qualified name (path) of
valueornull.
-
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 whenqnameis unknown.- Returns:
- The value corresponding to
qnameornull. - Throws:
cdc.util.lang.NotFoundException- Whenqnameis unknown andreactionisFailureReaction.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- Whenqnameis unknown.
-
hasValue
default boolean hasValue(String qname)
Returnstrueif a value with a qualified name is registered.- Parameters:
qname- The qualified name (path).- Returns:
trueif a value with is registered underqname.
-
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.
-
-