Record Class AttrOption<T>

java.lang.Object
java.lang.Record
com.iohao.net.common.kit.attr.AttrOption<T>
Type Parameters:
T - The type of the attribute value
All Implemented Interfaces:
Serializable

public record AttrOption<T>(String name, T defaultValue, Supplier<T> supplier) extends Record implements Serializable
Attribute option for dynamic attributes
Author:
渔民小镇
See Also:
date:
2022-01-31
  • Constructor Details

    • AttrOption

      public AttrOption(String name, T defaultValue, Supplier<T> supplier)
      Creates an instance of a AttrOption record class.
      Parameters:
      name - the value for the name record component
      defaultValue - the value for the defaultValue record component
      supplier - the value for the supplier record component
  • Method Details

    • valueOf

      public static <T> AttrOption<T> valueOf(String name)
      Initializes an AttrOption
      Type Parameters:
      T - The type of the attribute value
      Parameters:
      name - name
      Returns:
      AttrOption
    • valueOf

      public static <T> AttrOption<T> valueOf(String name, T defaultValue)
      Initializes an AttrOption
      Type Parameters:
      T - The type of the attribute value
      Parameters:
      name - name
      defaultValue - Default value (singleton)
      Returns:
      AttrOption
    • valueOf

      public static <T> AttrOption<T> valueOf(String name, Supplier<T> supplier)
      Initializes an AttrOption
      Type Parameters:
      T - The type of the attribute value
      Parameters:
      name - name
      supplier - Supplier to get the value from if the value does not exist
      Returns:
      AttrOption
    • equals

      public 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.
    • hashCode

      public 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
    • name

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

      public T defaultValue()
      Returns the value of the defaultValue record component.
      Returns:
      the value of the defaultValue record component
    • supplier

      public Supplier<T> supplier()
      Returns the value of the supplier record component.
      Returns:
      the value of the supplier record component