Record Class MachineDataKey<T>
java.lang.Object
java.lang.Record
fr.robie.machineengine.api.machine.MachineDataKey<T>
- Record Components:
id- unique within the machine typecodec- how the value is persisted and migrateddefaultValue- the value of a newly placed machine
public record MachineDataKey<T>(@NotNull String id, @NotNull VersionedCodec<T> codec, T defaultValue)
extends Record
A persisted value of a machine's own state (counters, modes, settings). Declared on the
MachineType; read and written through MachineContext.get(MachineDataKey)/MachineContext.set(MachineDataKey, T).
Values must be immutable.-
Constructor Summary
ConstructorsConstructorDescriptionMachineDataKey(@NotNull String id, @NotNull VersionedCodec<T> codec, T defaultValue) Creates an instance of aMachineDataKeyrecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull VersionedCodec<T> codec()Returns the value of thecodecrecord component.Returns the value of thedefaultValuerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull Stringid()Returns the value of theidrecord component.static <T> @NotNull MachineDataKey<T> of(@NotNull String id, @NotNull VersionedCodec<T> codec, T defaultValue) final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
MachineDataKey
public MachineDataKey(@NotNull @NotNull String id, @NotNull @NotNull VersionedCodec<T> codec, @NotNull T defaultValue) Creates an instance of aMachineDataKeyrecord class.- Parameters:
id- the value for theidrecord componentcodec- the value for thecodecrecord componentdefaultValue- the value for thedefaultValuerecord component
-
-
Method Details
-
of
@NotNull public static <T> @NotNull MachineDataKey<T> of(@NotNull @NotNull String id, @NotNull @NotNull VersionedCodec<T> codec, @NotNull T defaultValue) -
toString
-
hashCode
-
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). -
id
-
codec
-
defaultValue
Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-