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 booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull Stringname()Returns the value of thenamerecord component.intordinal()Returns the value of theordinalrecord component.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord 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 thenamerecord component.- Returns:
- the value of the
namerecord component
-
ordinal
public int ordinal()Returns the value of theordinalrecord component.- Returns:
- the value of the
ordinalrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-