Record Class EnumValue<E extends Enum<E>>

java.lang.Object
java.lang.Record
org.microbean.attributes.EnumValue<E>
Type Parameters:
E - the type of the Enum
Record Components:
value - the value
All Implemented Interfaces:
Comparable<EnumValue<E>>, Constable, Value<EnumValue<E>>

public record EnumValue<E extends Enum<E>>(E extends Enum<E> value) extends Record implements Value<EnumValue<E>>
A Value whose value is an Enum.
Author:
Laird Nelson
  • Constructor Details

  • Method Details

    • compareTo

      public final int compareTo(EnumValue<E> other)
      Specified by:
      compareTo in interface Comparable<E extends Enum<E>>
    • describeConstable

      Specified by:
      describeConstable in interface Constable
    • equals

      public final boolean equals(Object other)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      other - the object with which to compare
      Returns:
      true if this object is the same as the other argument; false otherwise.
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • of

      public static final <E extends Enum<E>> EnumValue<E> of(E e)
      Returns an EnumValue suitable for the supplied arguments.
      Type Parameters:
      E - the type of the Enum
      Parameters:
      e - a non-null Enum
      Returns:
      a non-null EnumValue
      Throws:
      NullPointerException - if e is null
    • value

      public E value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component