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
Type-safe attribute key for use with
AttrOptionDynamic. Supports default values
and lazy initialization via Supplier.- Author:
- 渔民小镇
- See Also:
- date:
- 2022-01-31
-
Constructor Summary
ConstructorsConstructorDescriptionAttrOption(String name, T defaultValue, Supplier<T> supplier) Creates an instance of aAttrOptionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedefaultValuerecord component.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.supplier()Returns the value of thesupplierrecord component.final StringtoString()Returns a string representation of this record class.static <T> AttrOption<T> Create an attribute option with no default value.static <T> AttrOption<T> Create an attribute option with a lazy default value supplier.static <T> AttrOption<T> Create an attribute option with a static default value.
-
Constructor Details
-
AttrOption
-
-
Method Details
-
valueOf
Create an attribute option with no default value.- Type Parameters:
T- the type of the attribute value- Parameters:
name- the unique name identifying this attribute option- Returns:
- a new
AttrOptioninstance with no default
-
valueOf
Create an attribute option with a static default value.- Type Parameters:
T- the type of the attribute value- Parameters:
name- the unique name identifying this attribute optiondefaultValue- the default value returned when no explicit value is set- Returns:
- a new
AttrOptioninstance with the given default
-
valueOf
Create an attribute option with a lazy default value supplier.- Type Parameters:
T- the type of the attribute value- Parameters:
name- the unique name identifying this attribute optionsupplier- supplier invoked to produce the default value when none is set- Returns:
- a new
AttrOptioninstance with the given supplier
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
hashCode
-
toString
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
defaultValue
Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-
supplier
-