Record Class EnumConstant

java.lang.Object
java.lang.Record
io.kubfly.sdk.buffer.EnumConstant
Record Components:
type - the type: the declaring class in Java (io.kubfly.ads.OrderStatus), the type name elsewhere; may be empty when the language has none at run time
name - the name of the constant (SHIPPED)
All Implemented Interfaces:
Serializable

public record EnumConstant(String type, String name) extends Record implements Serializable
An enum constant as the data holds it: its type and its name — never its ordinal, which changes when constants are reordered. A reader has no class to make a constant of (the data may come from another language), so it keeps both names; toString() is type.name.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    EnumConstant(String type, String name)
    Validates the components.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the name record component.
    of(Enum<?> value)
    The constant of a Java enum.
    The text form: type.name, or the name alone without a type.
    Returns the value of the type record component.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • EnumConstant

      public EnumConstant(String type, String name)
      Validates the components.
      Parameters:
      type - the type
      name - the name
      Throws:
      NullPointerException - if a component is null
  • Method Details

    • of

      public static EnumConstant of(Enum<?> value)
      The constant of a Java enum.
      Parameters:
      value - the constant
      Returns:
      its type and name
    • toString

      public String toString()
      The text form: type.name, or the name alone without a type.
      Specified by:
      toString in class Record
      Returns:
      the text
    • 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
    • equals

      public final boolean equals(Object o)
      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:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component