Package dev.latvian.mods.klib.data
Record Class DataTypeField.OptionalDefaultField<C,T>
java.lang.Object
java.lang.Record
dev.latvian.mods.klib.data.DataTypeField.OptionalDefaultField<C,T>
- All Implemented Interfaces:
DataTypeField<C,T>
- Enclosing interface:
DataTypeField<C,T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.latvian.mods.klib.data.DataTypeField
DataTypeField.OptionalDefaultField<C,T>, DataTypeField.OptionalField<C, T>, DataTypeField.RequiredField<C, T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean<O> com.mojang.serialization.DataResult<T> decode(com.mojang.serialization.DynamicOps<O> ops, O value) decode(io.netty.buffer.ByteBuf buf, boolean present) Returns the value of thedefaultValuerecord component.<O> voidencode(com.mojang.serialization.DynamicOps<O> ops, com.mojang.serialization.RecordBuilder<O> builder, T value) voidfinal booleanIndicates whether some other object is "equal to" this one.getter()Returns the value of thegetterrecord component.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.booleanshouldEncode(T value) final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
OptionalDefaultField
Creates an instance of aOptionalDefaultFieldrecord class.- Parameters:
type- the value for thetyperecord componentname- the value for thenamerecord componentgetter- the value for thegetterrecord componentdefaultValue- the value for thedefaultValuerecord component
-
-
Method Details
-
typeClass
- Specified by:
typeClassin interfaceDataTypeField<C,T>
-
get
- Specified by:
getin interfaceDataTypeField<C,T>
-
canBeOptional
public boolean canBeOptional()- Specified by:
canBeOptionalin interfaceDataTypeField<C,T>
-
shouldEncode
- Specified by:
shouldEncodein interfaceDataTypeField<C,T>
-
encode
public <O> void encode(com.mojang.serialization.DynamicOps<O> ops, com.mojang.serialization.RecordBuilder<O> builder, T value) - Specified by:
encodein interfaceDataTypeField<C,T>
-
decode
public <O> com.mojang.serialization.DataResult<T> decode(com.mojang.serialization.DynamicOps<O> ops, @Nullable O value) - Specified by:
decodein interfaceDataTypeField<C,T>
-
encode
- Specified by:
encodein interfaceDataTypeField<C,T>
-
decode
- Specified by:
decodein interfaceDataTypeField<C,T>
-
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. -
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. -
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). -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
name
Returns the value of thenamerecord component.- Specified by:
namein interfaceDataTypeField<C,T> - Returns:
- the value of the
namerecord component
-
getter
Returns the value of thegetterrecord component.- Returns:
- the value of the
getterrecord component
-
defaultValue
Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-