Class GenericDataType<T,Z>
java.lang.Object
com.jeff_media.morepersistentdatatypes.datatypes.GenericDataType<T,Z>
- Type Parameters:
T
- Primitive TypeZ
- Complex Type
- All Implemented Interfaces:
PersistentDataType<T,
Z>
A generic
PersistentDataType
. You can provide two functions for converting between the primitive and complex type.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bukkit.persistence.PersistentDataType
PersistentDataType.PrimitivePersistentDataType<T extends Object>
-
Field Summary
Fields inherited from interface org.bukkit.persistence.PersistentDataType
BYTE, BYTE_ARRAY, DOUBLE, FLOAT, INTEGER, INTEGER_ARRAY, LONG, LONG_ARRAY, SHORT, STRING, TAG_CONTAINER, TAG_CONTAINER_ARRAY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfromPrimitive
(T t, PersistentDataAdapterContext persistentDataAdapterContext) toPrimitive
(Z z, PersistentDataAdapterContext persistentDataAdapterContext)
-
Constructor Details
-
GenericDataType
public GenericDataType(Class<T> primitiveType, Class<Z> complexType, Function<T, Z> toComplex, Function<Z, T> toPrimitive) Creates a new generic PersistentDataType.- Parameters:
primitiveType
- Primitive type. Must be either byte, byte[], double, float, int, int[], long, long[], short, String, PersistentDataContainer or PersistentDataContainer[]complexType
- Complex typetoComplex
- Function to convert the primitive to the complex typetoPrimitive
- Function to convert the complex to the primitive type
-
-
Method Details
-
getPrimitiveType
- Specified by:
getPrimitiveType
in interfacePersistentDataType<T,
Z>
-
getComplexType
- Specified by:
getComplexType
in interfacePersistentDataType<T,
Z>
-
toPrimitive
@NotNull public T toPrimitive(@NotNull Z z, @NotNull PersistentDataAdapterContext persistentDataAdapterContext) - Specified by:
toPrimitive
in interfacePersistentDataType<T,
Z>
-
fromPrimitive
@NotNull public Z fromPrimitive(@NotNull T t, @NotNull PersistentDataAdapterContext persistentDataAdapterContext) - Specified by:
fromPrimitive
in interfacePersistentDataType<T,
Z>
-