- java.lang.Object
-
- com.pervasive.datarush.analytics.util.DynamicEnum
-
- All Implemented Interfaces:
Serializable
,Iterable<DynamicEnum.Value>
public final class DynamicEnum extends Object implements Iterable<DynamicEnum.Value>, Serializable
Provides enum-like semantics ( ordinal mapping ) for dynamically constructed data.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DynamicEnum.Builder
Builder for constructing new dynamic enumsstatic class
DynamicEnum.Value
A value of a given enumeration.
-
Constructor Summary
Constructors Constructor Description DynamicEnum(Iterable<String> values)
Creates a new DynamicEnum.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
DynamicEnum.Value
forName(String name)
Returns the Value that corresponds to the given name.DynamicEnum.Value
forOrdinal(int ordinal)
Returns the Value that corresponds to the given ordinal.int
hashCode()
Iterator<DynamicEnum.Value>
iterator()
Iterates over all the Values in the enumeration.Set<String>
names()
Returns the set of names.List<String>
namesList()
Returns the list of names.int
size()
Returns the number of values in the enumeration.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
DynamicEnum
public DynamicEnum(Iterable<String> values)
Creates a new DynamicEnum. Note that it is the responsibility of the consumer to construct instances of DynamicEnum in such a way that there will not be two instances of the "same" DynamicEnum present in the same hashmap at the same time.- Parameters:
values
- the values of this enum
-
-
Method Detail
-
forOrdinal
public DynamicEnum.Value forOrdinal(int ordinal)
Returns the Value that corresponds to the given ordinal.- Parameters:
ordinal
- The ordinal.- Returns:
- the Value that corresponds to the given ordinal.
- Throws:
ArrayIndexOutOfBoundsException
- If ordinal is not a valid ordinal.
-
forName
public DynamicEnum.Value forName(String name)
Returns the Value that corresponds to the given name.- Parameters:
name
- The name.- Returns:
- the value or null if name is not a valid name or name is null
-
iterator
public Iterator<DynamicEnum.Value> iterator()
Iterates over all the Values in the enumeration. Values will be returned in the order that they were added.- Specified by:
iterator
in interfaceIterable<DynamicEnum.Value>
-
names
public Set<String> names()
Returns the set of names. The returned set will be ordered by ordinal.- Returns:
- the set of names.
-
namesList
public List<String> namesList()
Returns the list of names. The returned list will be ordered by ordinal.- Returns:
- the list of names.
-
size
public int size()
Returns the number of values in the enumeration.- Returns:
- the number of values in the enumeration.
-
-