Interface PersistentDataType<P,C>

Type Parameters:
P - the primary object type that is stored in the given tag
C - the retrieved object type when applying this tag type
All Known Subinterfaces:
ListPersistentDataType<P,C>
All Known Implementing Classes:
PersistentDataType.BooleanPersistentDataType, PersistentDataType.PrimitivePersistentDataType

public interface PersistentDataType<P,C>
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 PersistentDataType with different complex types. This may be useful for the likes of a UUIDTagType:

 
 public class UUIDTagType implements PersistentDataType<byte[], UUID> {

         @Override
         public Class<byte[]> getPrimitiveType() {
             return byte[].class;
         }

         @Override
         public Class<UUID> getComplexType() {
             return UUID.class;
         }

         @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();
         }

         @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);
         }
     }
Any plugin owned implementation of this interface is required to define one of the existing primitive types found in this interface. Notably BOOLEAN is not a primitive type but a convenience type.