T
- the primary object type that is stored in the given tagZ
- the retrieved object type when applying this item tag typeItemTagType.PrimitiveTagType
PersistentDataType
as this part of the api is being replaced@Deprecated public interface ItemTagType<T,Z>
This interface can be used to create your own custom ItemTagType
with
different complex types. This may be useful for the likes of a
UUIDItemTagType:
public class UUIDItemTagType implements ItemTagType<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, ItemTagAdapterContext 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, ItemTagAdapterContext context) {
ByteBuffer bb = ByteBuffer.wrap(primitive);
long firstLong = bb.getLong();
long secondLong = bb.getLong();
return new UUID(firstLong, secondLong);
}
}
Modifier and Type | Interface | Description |
---|---|---|
static class |
ItemTagType.PrimitiveTagType<T> |
Deprecated.
A default implementation that simply exists to pass on the retrieved or
inserted value to the next layer.
|
Modifier and Type | Field | Description |
---|---|---|
static ItemTagType<Byte,Byte> |
BYTE |
Deprecated.
|
static ItemTagType<byte[],byte[]> |
BYTE_ARRAY |
Deprecated.
|
static ItemTagType<Double,Double> |
DOUBLE |
Deprecated.
|
static ItemTagType<Float,Float> |
FLOAT |
Deprecated.
|
static ItemTagType<Integer,Integer> |
INTEGER |
Deprecated.
|
static ItemTagType<int[],int[]> |
INTEGER_ARRAY |
Deprecated.
|
static ItemTagType<Long,Long> |
LONG |
Deprecated.
|
static ItemTagType<long[],long[]> |
LONG_ARRAY |
Deprecated.
|
static ItemTagType<Short,Short> |
SHORT |
Deprecated.
|
static ItemTagType<String,String> |
STRING |
Deprecated.
|
static ItemTagType<CustomItemTagContainer,CustomItemTagContainer> |
TAG_CONTAINER |
Deprecated.
|
Modifier and Type | Method | Description |
---|---|---|
Z |
fromPrimitive(T primitive,
ItemTagAdapterContext context) |
Deprecated.
Creates a complex object based of the passed primitive value
|
Class<Z> |
getComplexType() |
Deprecated.
Returns the complex object type the primitive value resembles.
|
Class<T> |
getPrimitiveType() |
Deprecated.
Returns the primitive data type of this tag.
|
T |
toPrimitive(Z complex,
ItemTagAdapterContext context) |
Deprecated.
Returns the primitive data that resembles the complex object passed to
this method.
|
static final ItemTagType<Byte,Byte> BYTE
static final ItemTagType<Short,Short> SHORT
static final ItemTagType<Integer,Integer> INTEGER
static final ItemTagType<Long,Long> LONG
static final ItemTagType<Float,Float> FLOAT
static final ItemTagType<Double,Double> DOUBLE
static final ItemTagType<String,String> STRING
static final ItemTagType<byte[],byte[]> BYTE_ARRAY
static final ItemTagType<int[],int[]> INTEGER_ARRAY
static final ItemTagType<long[],long[]> LONG_ARRAY
static final ItemTagType<CustomItemTagContainer,CustomItemTagContainer> TAG_CONTAINER
@NotNull Class<T> getPrimitiveType()
@NotNull Class<Z> getComplexType()
@NotNull T toPrimitive(@NotNull Z complex, @NotNull ItemTagAdapterContext context)
complex
- the complex object instancecontext
- the context this operation is running in@NotNull Z fromPrimitive(@NotNull T primitive, @NotNull ItemTagAdapterContext context)
primitive
- the primitive valuecontext
- the context this operation is running inCopyright © 2019. All rights reserved.