Record Class Immutable<T>
java.lang.Object
java.lang.Record
com.github.codeboyzhou.mcp.declarative.common.Immutable<T>
- 类型参数:
T- the type of the value
A simple immutable wrapper class for a single value. Instances of this class are immutable,
meaning that once created, their value cannot be changed.
- 作者:
- codeboyzhou
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明final boolean指示某个其他对象是否“等于”此对象。get()Returns the value wrapped by thisImmutableinstance.final inthashCode()返回此对象的哈希代码值。static <T> Immutable<T>of(T value) Creates a new instance ofImmutablewith the specified value.final StringtoString()返回此记录的字符串表示形式。value()返回value记录组件的值。
-
构造器详细资料
-
Immutable
创建Immutable记录的实例。- 参数:
value-value记录组件的值
-
-
方法详细资料
-
of
Creates a new instance ofImmutablewith the specified value.- 类型参数:
T- the type of the value- 参数:
value- the value to be wrapped- 返回:
- a new instance of
Immutablewith the specified value
-
get
Returns the value wrapped by thisImmutableinstance. It can also usevalue()to get the value, but#get()is more readable.- 返回:
- the value wrapped by this
Immutableinstance
-
toString
返回此记录的字符串表示形式。此表示形式包含类型的名称,后跟每个记录组件的名称和值。 -
hashCode
public final int hashCode()返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。 -
equals
指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 此记录中的所有组件都使用Objects::equals(Object,Object)进行比较。 -
value
返回value记录组件的值。- 返回:
value记录组件的值
-