接口 PersistentDataType<P,C>
- 类型参数:
P
- the primary object type that is stored in the given tagC
- the retrieved object type when applying this tag type
- 所有已知子接口:
ListPersistentDataType<P,
C>
- 所有已知实现类:
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.-
嵌套类概要
修饰符和类型接口说明static class
A convenience implementation to convert between Byte and Boolean as there is no native implementation for booleans.static class
A default implementation that simply exists to pass on the retrieved or inserted value to the next layer. -
字段概要
修饰符和类型字段说明static final PersistentDataType<Byte,
Boolean> A convenience implementation to convert between Byte and Boolean as there is no native implementation for booleans.static final PersistentDataType<Byte,
Byte> static final PersistentDataType<byte[],
byte[]> static final PersistentDataType<Double,
Double> static final PersistentDataType<Float,
Float> static final PersistentDataType<Integer,
Integer> static final PersistentDataType<int[],
int[]> static final ListPersistentDataTypeProvider
A data type provider type that itself cannot be used as aPersistentDataType
.static final PersistentDataType<Long,
Long> static final PersistentDataType<long[],
long[]> static final PersistentDataType<Short,
Short> static final PersistentDataType<String,
String> static final PersistentDataType<PersistentDataContainer,
PersistentDataContainer> static final PersistentDataType<PersistentDataContainer[],
PersistentDataContainer[]> 已过时。 -
方法概要
修饰符和类型方法说明fromPrimitive
(P primitive, @NotNull PersistentDataAdapterContext context) Creates a complex object based of the passed primitive valueReturns the complex object type the primitive value resembles.Returns the primitive data type of this tag.toPrimitive
(C complex, @NotNull PersistentDataAdapterContext context) Returns the primitive data that resembles the complex object passed to this method.
-
字段详细资料
-
BYTE
-
SHORT
-
INTEGER
-
LONG
-
FLOAT
-
DOUBLE
-
BOOLEAN
A convenience implementation to convert between Byte and Boolean as there is no native implementation for booleans.
Any byte value not equal to 0 is considered to be true. -
STRING
-
BYTE_ARRAY
-
INTEGER_ARRAY
-
LONG_ARRAY
-
TAG_CONTAINER_ARRAY
@Deprecated static final PersistentDataType<PersistentDataContainer[],PersistentDataContainer[]> TAG_CONTAINER_ARRAY已过时。UseLIST
'sListPersistentDataTypeProvider.dataContainers()
instead asListPersistentDataType
s offer full support for primitive types, such as thePersistentDataContainer
. -
TAG_CONTAINER
-
LIST
A data type provider type that itself cannot be used as aPersistentDataType
.ListPersistentDataTypeProvider
exposes shared persistent data types for storing lists of other data types, however.Its existence in the
PersistentDataType
interface does not permitList
as a primitive type in combination with a plainPersistentDataType
.List
s are only valid primitive types when used via aListPersistentDataType
.
-
-
方法详细资料
-
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
@NotNull C fromPrimitive(@NotNull P primitive, @NotNull @NotNull PersistentDataAdapterContext context) 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
-
LIST
'sListPersistentDataTypeProvider.dataContainers()
instead asListPersistentDataType
s offer full support for primitive types, such as thePersistentDataContainer
.