接口 ItemTagType<T,Z>
- 类型参数:
T
- the primary object type that is stored in the given tagZ
- the retrieved object type when applying this item tag type
- 所有已知实现类:
ItemTagType.PrimitiveTagType
已过时。
This class represents an enum with a generic content type. It defines the
types a custom item tag can have.
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);
}
}
-
嵌套类概要
修饰符和类型接口说明static class
已过时。A default implementation that simply exists to pass on the retrieved or inserted value to the next layer. -
字段概要
修饰符和类型字段说明static final ItemTagType<Byte,
Byte> 已过时。static final ItemTagType<byte[],
byte[]> 已过时。static final ItemTagType<Double,
Double> 已过时。static final ItemTagType<Float,
Float> 已过时。static final ItemTagType<Integer,
Integer> 已过时。static final ItemTagType<int[],
int[]> 已过时。static final ItemTagType<Long,
Long> 已过时。static final ItemTagType<long[],
long[]> 已过时。static final ItemTagType<Short,
Short> 已过时。static final ItemTagType<String,
String> 已过时。static final ItemTagType<CustomItemTagContainer,
CustomItemTagContainer> 已过时。 -
方法概要
修饰符和类型方法说明fromPrimitive
(T primitive, @NotNull ItemTagAdapterContext context) 已过时。Creates a complex object based of the passed primitive value已过时。Returns the complex object type the primitive value resembles.已过时。Returns the primitive data type of this tag.toPrimitive
(Z complex, @NotNull ItemTagAdapterContext context) 已过时。Returns the primitive data that resembles the complex object passed to this method.
-
字段详细资料
-
BYTE
已过时。 -
SHORT
已过时。 -
INTEGER
已过时。 -
LONG
已过时。 -
FLOAT
已过时。 -
DOUBLE
已过时。 -
STRING
已过时。 -
BYTE_ARRAY
已过时。 -
INTEGER_ARRAY
已过时。 -
LONG_ARRAY
已过时。 -
TAG_CONTAINER
已过时。
-
-
方法详细资料
-
getPrimitiveType
已过时。Returns the primitive data type of this tag.- 返回:
- the class
-
getComplexType
已过时。Returns the complex object type the primitive value resembles.- 返回:
- the class type
-
toPrimitive
已过时。Returns the primitive data that resembles the complex object passed to this method.- 参数:
complex
- the complex object instancecontext
- the context this operation is running in- 返回:
- the primitive value
-
fromPrimitive
已过时。Creates a complex object based of the passed primitive value- 参数:
primitive
- the primitive valuecontext
- the context this operation is running in- 返回:
- the complex object instance
-
PersistentDataType
as this part of the api is being replaced