Package eu.bandm.tools.util.classes
Class DynamicEnum<T>
java.lang.Object
eu.bandm.tools.util.classes.DynamicEnum<T>
- All Implemented Interfaces:
Index<DynamicEnum.Item<T>>
,Serializable
,Iterable<DynamicEnum.Item<T>>
- Direct Known Subclasses:
DynamicEnum.Coproduct
,DynamicEnum.Product
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An enumeration type which comprises all items from a set of underlying enumeration types.static class
Wrapper for one single data item added to the enumeration.static class
The product of multiple DynamicEnum realized as one DynamicEnum of tuples. -
Constructor Summary
ConstructorDescriptionConstructor for an emtpy enumeration.DynamicEnum
(@Opt T... items) Constructor for an enumeration with fixed content.DynamicEnum
(Collection<? extends @Opt T> items) Constructor for an enumeration with fixed content. -
Method Summary
Modifier and TypeMethodDescriptionAdd one item.boolean
Returns whether the argument is contained in this enumeration.boolean
Returns whether the argument is contained in this enumeration.boolean
Returns whether the argument is contained in this enumeration.get
(int i) Returns the added item by its position number, or null if no such found.int
indexOf
(DynamicEnum.Item<T> i) Returns the number of the item in this enumeration, or -1 if not contained.int
Returns the number of the item in this enumeration, or -1 if not contained.items()
evidentiterator()
void
seal()
Set the sealed flag to indicate that the definition is complete.int
size()
Returns the number of objects in this index.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.tools.ops.Index
comparator, enumerate, isEmpty
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
DynamicEnum
public DynamicEnum()Constructor for an emtpy enumeration. Must be filled by successive calls toadd(T)
. -
DynamicEnum
Constructor for an enumeration with fixed content. No further addtions may happen. -
DynamicEnum
Constructor for an enumeration with fixed content. No further addtions may happen.
-
-
Method Details
-
add
Add one item.- Throws:
IllegalStateException
- if sealed flag is set.
-
seal
public void seal()Set the sealed flag to indicate that the definition is complete. Must be called after the last call toadd(T)
. -
size
public int size()Description copied from interface:Index
Returns the number of objects in this index. This number is nonnegative. -
iterator
-
items
evident -
get
Returns the added item by its position number, or null if no such found. -
indexOf
Returns the number of the item in this enumeration, or -1 if not contained. -
indexOfUnchecked
Returns the number of the item in this enumeration, or -1 if not contained.- Specified by:
indexOfUnchecked
in interfaceIndex<T>
-
contains
Returns whether the argument is contained in this enumeration. -
containsSemichecked
Returns whether the argument is contained in this enumeration. -
containsUnchecked
Returns whether the argument is contained in this enumeration.- Specified by:
containsUnchecked
in interfaceIndex<T>
-