Record Class ItemMarker<P,C>
java.lang.Object
java.lang.Record
com.ultikits.ultitools.item.ItemMarker<P,C>
- Type Parameters:
P- primitive storage typeC- complex value type- Record Components:
key- persistent-data keytype- value codecvalue- value to store
public record ItemMarker<P,C> (org.bukkit.NamespacedKey key, org.bukkit.persistence.PersistentDataType<P,C> type, C value)
extends Record
A persistent-data value written onto the rendered stack (
ItemStack#editPersistentDataContainer).
Deeply immutable and value-equal: an array value (of any component type) is copied in the
constructor and on every value() call; a List value is copied with
List.copyOf after its elements are frozen the same way. Equality and hash code compare array
contents deeply and lists element by element. A PersistentDataContainer value, an array of
them, or a list containing one is rejected, because a container is mutable and has no value
equality; store a key or a byte array instead. A value of a module-defined complex type must itself
be immutable with value equals; otherwise equal specs compare unequal and a GUI re-renders.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionItemMarker(org.bukkit.NamespacedKey key, org.bukkit.persistence.PersistentDataType<P, C> type, C value) Rejects nulls and container values, and freezes supported aggregate values. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> Tcopy(T value) booleanCompares array contents deeply and list elements by value.private static booleanequalValues(Object first, Object second) private static Objectprivate static ObjectfreezeArray(Object value) freezeList(List<?> list) inthashCode()Returns a content-based hash matchingequals(Object).org.bukkit.NamespacedKeykey()Returns the value of thekeyrecord component.toString()Returns record-style diagnostics with array contents rather than array identities.type()Returns the value of thetyperecord component.value()Returns the value, defensively copying arrays and aggregate elements on every call.private static intprivate static String
-
Field Details
-
key
private final org.bukkit.NamespacedKey keyThe field for thekeyrecord component. -
type
-
value
-
-
Constructor Details
-
ItemMarker
public ItemMarker(org.bukkit.NamespacedKey key, org.bukkit.persistence.PersistentDataType<P, C> type, C value) Rejects nulls and container values, and freezes supported aggregate values.- Throws:
IllegalArgumentException- for a container value
-
-
Method Details
-
value
Returns the value, defensively copying arrays and aggregate elements on every call. -
equals
-
hashCode
public int hashCode()Returns a content-based hash matchingequals(Object). -
toString
-
copy
private static <T> T copy(T value) -
freeze
-
freezeList
-
freezeArray
-
equalValues
-
valueHash
-
valueText
-
key
-
type
-