Package org.bukkit.persistence
Interface PersistentDataType<T,Z>
- 
- Type Parameters:
- T- the primary object type that is stored in the given tag
- Z- the retrieved object type when applying this tag type
 - All Known Implementing Classes:
- PersistentDataType.PrimitivePersistentDataType
 
 public interface PersistentDataType<T,Z>This class represents an enum with a generic content type. It defines the types a custom tag can have.This interface can be used to create your own custom PersistentDataTypewith different complex types. This may be useful for the likes of a UUIDTagType:public class UUIDTagType implements PersistentDataType<byte[], UUID> { {@literal @Override} public Class<byte[]> getPrimitiveType() { return byte[].class; } {@literal @Override} public Class<UUID> getComplexType() { return UUID.class; } {@literal @Override} public byte[] toPrimitive(UUID complex, PersistentDataAdapterContext context) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(complex.getMostSignificantBits()); bb.putLong(complex.getLeastSignificantBits()); return bb.array(); } {@literal @Override} public UUID fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) { ByteBuffer bb = ByteBuffer.wrap(primitive); long firstLong = bb.getLong(); long secondLong = bb.getLong(); return new UUID(firstLong, secondLong); } }
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static classPersistentDataType.PrimitivePersistentDataType<T>A default implementation that simply exists to pass on the retrieved or inserted value to the next layer.
 - 
Field SummaryFields Modifier and Type Field Description static PersistentDataType<Byte,Byte>BYTEstatic PersistentDataType<byte[],byte[]>BYTE_ARRAYstatic PersistentDataType<Double,Double>DOUBLEstatic PersistentDataType<Float,Float>FLOATstatic PersistentDataType<Integer,Integer>INTEGERstatic PersistentDataType<int[],int[]>INTEGER_ARRAYstatic PersistentDataType<Long,Long>LONGstatic PersistentDataType<long[],long[]>LONG_ARRAYstatic PersistentDataType<Short,Short>SHORTstatic PersistentDataType<String,String>STRINGstatic PersistentDataType<PersistentDataContainer,PersistentDataContainer>TAG_CONTAINER
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description ZfromPrimitive(T primitive, PersistentDataAdapterContext context)Creates a complex object based of the passed primitive valueClass<Z>getComplexType()Returns the complex object type the primitive value resembles.Class<T>getPrimitiveType()Returns the primitive data type of this tag.TtoPrimitive(Z complex, PersistentDataAdapterContext context)Returns the primitive data that resembles the complex object passed to this method.
 
- 
- 
- 
Field Detail- 
BYTEstatic final PersistentDataType<Byte,Byte> BYTE 
 - 
SHORTstatic final PersistentDataType<Short,Short> SHORT 
 - 
INTEGERstatic final PersistentDataType<Integer,Integer> INTEGER 
 - 
LONGstatic final PersistentDataType<Long,Long> LONG 
 - 
FLOATstatic final PersistentDataType<Float,Float> FLOAT 
 - 
DOUBLEstatic final PersistentDataType<Double,Double> DOUBLE 
 - 
STRINGstatic final PersistentDataType<String,String> STRING 
 - 
BYTE_ARRAYstatic final PersistentDataType<byte[],byte[]> BYTE_ARRAY 
 - 
INTEGER_ARRAYstatic final PersistentDataType<int[],int[]> INTEGER_ARRAY 
 - 
LONG_ARRAYstatic final PersistentDataType<long[],long[]> LONG_ARRAY 
 - 
TAG_CONTAINERstatic final PersistentDataType<PersistentDataContainer,PersistentDataContainer> TAG_CONTAINER 
 
- 
 - 
Method Detail- 
getPrimitiveType@NotNull Class<T> getPrimitiveType() Returns the primitive data type of this tag.- Returns:
- the class
 
 - 
getComplexType@NotNull Class<Z> getComplexType() Returns the complex object type the primitive value resembles.- Returns:
- the class type
 
 - 
toPrimitive@NotNull T toPrimitive(@NotNull Z complex, @NotNull PersistentDataAdapterContext context) Returns the primitive data that resembles the complex object passed to this method.- Parameters:
- complex- the complex object instance
- context- the context this operation is running in
- Returns:
- the primitive value
 
 - 
fromPrimitive@NotNull Z fromPrimitive(@NotNull T primitive, @NotNull PersistentDataAdapterContext context) Creates a complex object based of the passed primitive value- Parameters:
- primitive- the primitive value
- context- the context this operation is running in
- Returns:
- the complex object instance
 
 
- 
 
-