java.lang.Object
java.lang.Record
net.luis.utils.lang.EnumConstant<T>
- Type Parameters:
T
- The type of the enum constant- Record Components:
name
- The name of the enum constantordinal
- The ordinal of the enum constantvalue
- The value of the enum constant
A record that represents an enum constant.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEnumConstant
(@NotNull String name, int ordinal, T value) Constructs a new enum constant with the given name, ordinal and value. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.@NotNull String
name()
Returns the value of thename
record component.int
ordinal()
Returns the value of theordinal
record component.final String
toString()
Returns a string representation of this record class.value()
Returns the value of thevalue
record component.
-
Field Details
-
Constructor Details
-
EnumConstant
Constructs a new enum constant with the given name, ordinal and value.- Parameters:
name
- The name of the enum constantordinal
- The ordinal of the enum constantvalue
- The value of the enum constant- Throws:
NullPointerException
- If the given name or value is nullIllegalArgumentException
- If the given ordinal is negative
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
name
Returns the value of thename
record component.- Returns:
- the value of the
name
record component
-
ordinal
public int ordinal()Returns the value of theordinal
record component.- Returns:
- the value of the
ordinal
record component
-
value
Returns the value of thevalue
record component.- Returns:
- the value of the
value
record component
-