Package io.permazen.core
Class EnumValue
java.lang.Object
io.permazen.core.EnumValue
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
EnumValue
Constructor taking name and ordinal value.- Parameters:
name- enum nameordinal- enum ordinal value- Throws:
IllegalArgumentException- ifordinalis negativeIllegalArgumentException- ifnameis null
-
EnumValue
Constructor taking anEnumvalue.- Parameters:
value- enum value- Throws:
IllegalArgumentException- ifvalueis null
-
-
Method Details
-
getName
Get the enum name.- Returns:
- enum value name
-
getOrdinal
public int getOrdinal()Get the enum ordinal value.- Returns:
- enum value ordinal
-
find
Find the instance in the givenEnumtype 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-Enumtype- Returns:
- matching instance of type
type, or null if none exists - Throws:
IllegalArgumentException- iftypeis null
-
toString
-
hashCode
public int hashCode() -
equals
-