- Type Parameters:
D
- the intermediary type used by the transcoder
- All Known Subinterfaces:
TranscoderProxy<D>
- All Known Implementing Classes:
RegistryTranscoder
public interface Transcoder<D>
Transcoders are responsible for converting "primitive" java objects into their respective
Commonly used transcoders are accessible through static fields like
Transcoder
types.
They are also responsible for unwrapping these objects back to their primitives.
Commonly used transcoders are accessible through static fields like
JSON
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
List builders are used to eventually build a list.static interface
Map builders are used to eventually build a map
They are considered mutable containers, but provide builder semantics.static interface
Represents an immutableMap
like object. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Transcoder
<Integer> static final Transcoder
<Object> static final Transcoder
<JsonElement> static final Transcoder
<BinaryTag> -
Method Summary
Modifier and TypeMethodDescription<O> Result
<O> convertTo
(Transcoder<O> coder, D value) Converts the current intermediary ofTranscoder
into intermediaryTranscoder
createBoolean
(boolean value) Creates a boolean representation ofTranscoder
createByte
(byte value) Creates a byte representation ofTranscoder
default D
createByteArray
(byte[] value) Creates abyte[]
representation ofTranscoder
createDouble
(double value) Creates a float representation ofTranscoder
createFloat
(float value) Creates a float representation ofTranscoder
createInt
(int value) Creates an int representation ofTranscoder
default D
createIntArray
(int[] value) Creates aint[]
representation ofTranscoder
createList
(int expectedSize) Creates aTranscoder.ListBuilder
createLong
(long value) Creates a long representation ofTranscoder
default D
createLongArray
(long[] value) Creates along[]
representation ofTranscoder
Creates aTranscoder.MapBuilder
Creates a null representation ofTranscoder
createShort
(short value) Creates a short representation ofTranscoder
createString
(String value) Creates a string representation ofTranscoder
default D
A empty list intermediarydefault D
emptyMap()
A emtpy map intermediarygetBoolean
(D value) Attempts to unwrap a boolean from the valueTranscoder
Attempts to unwrap a byte from the valueTranscoder
default Result
<byte[]> getByteArray
(D value) Attempts to unwrap abyte[]
from the valueTranscoder
Attempts to unwrap a double from the valueTranscoder
Attempts to unwrap a float from the valueTranscoder
Attempts to unwrap an int from the valueTranscoder
default Result
<int[]> getIntArray
(D value) Attempts to unwrap aint[]
from the valueTranscoder
Attempts to unwrap a list from the valueTranscoder
TheList
decoded possibly has more ofTranscoder
contained inside.Attempts to unwrap a long from the valueTranscoder
default Result
<long[]> getLongArray
(D value) Attempts to unwrap along[]
from the valueTranscoder
Attempts to unwrap a map from the valueTranscoder
TheTranscoder.MapLike
decoded possibly has more ofTranscoder
contained inside.Attempts to unwrap a short from the valueTranscoder
Attempts to unwrap a string from the valueTranscoder
-
Field Details
-
NBT
-
JSON
-
JAVA
-
CRC32_HASH
-
-
Method Details
-
createNull
D createNull()Creates a null representation ofTranscoder
- Returns:
- the null object, never
null
-
getBoolean
Attempts to unwrap a boolean from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createBoolean
Creates a boolean representation ofTranscoder
- Parameters:
value
- the boolean primitive- Returns:
- the representation of value in
Transcoder
-
getByte
Attempts to unwrap a byte from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createByte
Creates a byte representation ofTranscoder
- Parameters:
value
- the byte primitive- Returns:
- the representation of value in
Transcoder
-
getShort
Attempts to unwrap a short from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createShort
Creates a short representation ofTranscoder
- Parameters:
value
- the short primitive- Returns:
- the representation of value in
Transcoder
-
getInt
Attempts to unwrap an int from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createInt
Creates an int representation ofTranscoder
- Parameters:
value
- the int primitive- Returns:
- the representation of value in
Transcoder
-
getLong
Attempts to unwrap a long from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createLong
Creates a long representation ofTranscoder
- Parameters:
value
- the long primitive- Returns:
- the representation of value in
Transcoder
-
getFloat
Attempts to unwrap a float from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createFloat
Creates a float representation ofTranscoder
- Parameters:
value
- the float primitive- Returns:
- the representation of value in
Transcoder
-
getDouble
Attempts to unwrap a double from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createDouble
Creates a float representation ofTranscoder
- Parameters:
value
- the float primitive- Returns:
- the representation of value in
Transcoder
-
getString
Attempts to unwrap a string from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createString
Creates a string representation ofTranscoder
- Parameters:
value
- the string primitive- Returns:
- the representation of value in
Transcoder
-
getList
Attempts to unwrap a list from the valueTranscoder
TheList
decoded possibly has more ofTranscoder
contained inside.- Parameters:
value
- the value to unwrap- Returns:
- the result
-
emptyList
A empty list intermediary- Returns:
- the empty list intermediary
-
createList
Creates aTranscoder.ListBuilder
- Parameters:
expectedSize
- the initial size- Returns:
- a list builder
-
getMap
Attempts to unwrap a map from the valueTranscoder
TheTranscoder.MapLike
decoded possibly has more ofTranscoder
contained inside.- Parameters:
value
- the value to unwrap- Returns:
- the result
-
emptyMap
A emtpy map intermediary- Returns:
- the empty map intermediary
-
createMap
Creates aTranscoder.MapBuilder
- Returns:
- a new
Transcoder.MapBuilder
-
getByteArray
Attempts to unwrap abyte[]
from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createByteArray
Creates abyte[]
representation ofTranscoder
- Parameters:
value
- the byte array- Returns:
Transcoder
representation ofbyte[]
-
getIntArray
Attempts to unwrap aint[]
from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createIntArray
Creates aint[]
representation ofTranscoder
- Parameters:
value
- the int array- Returns:
Transcoder
representation ofint[]
-
getLongArray
Attempts to unwrap along[]
from the valueTranscoder
- Parameters:
value
- the value to unwrap- Returns:
- the result
-
createLongArray
Creates along[]
representation ofTranscoder
- Parameters:
value
- the long array- Returns:
Transcoder
representation oflong[]
-
convertTo
Converts the current intermediary ofTranscoder
into intermediaryTranscoder
- Type Parameters:
O
- the intermediary type to convert to- Parameters:
coder
- the transcoder to convert tovalue
- the value to convert- Returns:
- the resultant of the conversion
-