Class DynamicEnum

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:
  • Constructor Details

    • 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 Details

    • 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 interface Iterable<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.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object