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 Details
-
EnumValue
Constructor taking name and ordinal value.- Parameters:
name
- enum nameordinal
- enum ordinal value- Throws:
IllegalArgumentException
- ifordinal
is negativeIllegalArgumentException
- ifname
is null
-
EnumValue
Constructor taking anEnum
value.- Parameters:
value
- enum value- Throws:
IllegalArgumentException
- ifvalue
is 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 givenEnum
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
- iftype
is null
-
toString
-
hashCode
public int hashCode() -
equals
-