Class EnumValue

java.lang.Object
io.permazen.core.EnumValue
All Implemented Interfaces:
Serializable

public class EnumValue extends Object implements Serializable
Holds a non-null Enum value without actually referencing any Java Enum type. Instead, instances hold a name and ordinal value.

Instances are immutable.

See Also:
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Get the enum name.
      Returns:
      enum value name
    • getOrdinal

      public int getOrdinal()
      Get the enum ordinal value.
      Returns:
      enum value ordinal
    • find

      public <T extends Enum<T>> T find(Class<T> type)
      Find the instance in the given Enum type that matches this instance in both name and ordinal value, if any.

      Note: to match only by name, just use Enum.valueOf().

      Type Parameters:
      T - enum type
      Parameters:
      type - Enum type
      Returns:
      matching instance of type type, or null if none exists
      Throws:
      IllegalArgumentException - if type is null
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

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

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