Interface TranscoderProxy<D>
- Type Parameters:
D- the type of the delegate transcoder
- All Superinterfaces:
Transcoder<D>
- All Known Implementing Classes:
RegistryTranscoder
Proxies all transcoder calls to the given delegate. Exists to allow passing context into
codec implementations by creating
Transcoder subclasses.
Note: TranscoderProxy has some special handling assuming that all calls are forwarded. If that is not the case, you should inherit from Transcoder itself and NOT TranscoderProxy.
-
Nested Class Summary
Nested classes/interfaces inherited from interface Transcoder
Transcoder.ListBuilder<D>, Transcoder.MapBuilder<D>, Transcoder.MapLike<D> -
Field Summary
Fields inherited from interface Transcoder
CRC32_HASH, JAVA, JSON, NBT -
Method Summary
Modifier and TypeMethodDescriptiondefault <O> Result<O> convertTo(Transcoder<O> coder, D value) default DcreateBoolean(boolean value) Creates a boolean representation ofDdefault DcreateByte(byte value) Creates a byte representation ofDdefault DcreateByteArray(byte[] value) Creates abyte[]representation ofDdefault DcreateDouble(double value) Creates a float representation ofDdefault DcreateFloat(float value) Creates a float representation ofDdefault DcreateInt(int value) Creates an int representation ofDdefault DcreateIntArray(int[] value) Creates aint[]representation ofDdefault Transcoder.ListBuilder<D> createList(int expectedSize) Creates aTranscoder.ListBuilderdefault DcreateLong(long value) Creates a long representation ofDdefault DcreateLongArray(long[] value) Creates along[]representation ofDdefault Transcoder.MapBuilder<D> Creates aTranscoder.MapBuilderdefault DCreates a null representation ofDdefault DcreateShort(short value) Creates a short representation ofDdefault DcreateString(String value) Creates a string representation ofDdelegate()The delegate to use; This should be considered immutable during its lifetime.static <D> Transcoder<D> extractDelegate(Transcoder<D> transcoder) Recursively extracts the delegate from aTranscoderProxy.getBoolean(D value) Attempts to unwrap a boolean from the valueDAttempts to unwrap a byte from the valueDdefault Result<byte[]> getByteArray(D value) Attempts to unwrap abyte[]from the valueDAttempts to unwrap a double from the valueDAttempts to unwrap a float from the valueDAttempts to unwrap an int from the valueDdefault Result<int[]> getIntArray(D value) Attempts to unwrap aint[]from the valueDAttempts to unwrap a long from the valueDdefault Result<long[]> getLongArray(D value) Attempts to unwrap along[]from the valueDdefault Result<Transcoder.MapLike<D>> Attempts to unwrap a map from the valueD
TheTranscoder.MapLikedecoded possibly has more ofDcontained inside.Attempts to unwrap a short from the valueDAttempts to unwrap a string from the valueDMethods inherited from interface Transcoder
emptyList, emptyMap
-
Method Details
-
extractDelegate
Recursively extracts the delegate from aTranscoderProxy.- Parameters:
transcoder- The transcoder (possibly proxy) to extract- Returns:
- The delegate transcoder
-
delegate
Transcoder<D> delegate()The delegate to use; This should be considered immutable during its lifetime.- Returns:
- the
Transcoderdelegated forTranscoderProxy
-
createNull
Description copied from interface:TranscoderCreates a null representation ofD- Specified by:
createNullin interfaceTranscoder<D>- Returns:
- the null object, never
null
-
getBoolean
Description copied from interface:TranscoderAttempts to unwrap a boolean from the valueD- Specified by:
getBooleanin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createBoolean
Description copied from interface:TranscoderCreates a boolean representation ofD- Specified by:
createBooleanin interfaceTranscoder<D>- Parameters:
value- the boolean primitive- Returns:
- the representation of value in
D
-
getByte
Description copied from interface:TranscoderAttempts to unwrap a byte from the valueD- Specified by:
getBytein interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createByte
Description copied from interface:TranscoderCreates a byte representation ofD- Specified by:
createBytein interfaceTranscoder<D>- Parameters:
value- the byte primitive- Returns:
- the representation of value in
D
-
getShort
Description copied from interface:TranscoderAttempts to unwrap a short from the valueD- Specified by:
getShortin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createShort
Description copied from interface:TranscoderCreates a short representation ofD- Specified by:
createShortin interfaceTranscoder<D>- Parameters:
value- the short primitive- Returns:
- the representation of value in
D
-
getInt
Description copied from interface:TranscoderAttempts to unwrap an int from the valueD- Specified by:
getIntin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createInt
Description copied from interface:TranscoderCreates an int representation ofD- Specified by:
createIntin interfaceTranscoder<D>- Parameters:
value- the int primitive- Returns:
- the representation of value in
D
-
getLong
Description copied from interface:TranscoderAttempts to unwrap a long from the valueD- Specified by:
getLongin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createLong
Description copied from interface:TranscoderCreates a long representation ofD- Specified by:
createLongin interfaceTranscoder<D>- Parameters:
value- the long primitive- Returns:
- the representation of value in
D
-
getFloat
Description copied from interface:TranscoderAttempts to unwrap a float from the valueD- Specified by:
getFloatin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createFloat
Description copied from interface:TranscoderCreates a float representation ofD- Specified by:
createFloatin interfaceTranscoder<D>- Parameters:
value- the float primitive- Returns:
- the representation of value in
D
-
getDouble
Description copied from interface:TranscoderAttempts to unwrap a double from the valueD- Specified by:
getDoublein interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createDouble
Description copied from interface:TranscoderCreates a float representation ofD- Specified by:
createDoublein interfaceTranscoder<D>- Parameters:
value- the float primitive- Returns:
- the representation of value in
D
-
getString
Description copied from interface:TranscoderAttempts to unwrap a string from the valueD- Specified by:
getStringin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createString
Description copied from interface:TranscoderCreates a string representation ofD- Specified by:
createStringin interfaceTranscoder<D>- Parameters:
value- the string primitive- Returns:
- the representation of value in
D
-
createByteArray
Description copied from interface:TranscoderCreates abyte[]representation ofD- Specified by:
createByteArrayin interfaceTranscoder<D>- Parameters:
value- the byte array- Returns:
Drepresentation ofbyte[]
-
getByteArray
Description copied from interface:TranscoderAttempts to unwrap abyte[]from the valueD- Specified by:
getByteArrayin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createIntArray
Description copied from interface:TranscoderCreates aint[]representation ofD- Specified by:
createIntArrayin interfaceTranscoder<D>- Parameters:
value- the int array- Returns:
Drepresentation ofint[]
-
getIntArray
Description copied from interface:TranscoderAttempts to unwrap aint[]from the valueD- Specified by:
getIntArrayin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createLongArray
Description copied from interface:TranscoderCreates along[]representation ofD- Specified by:
createLongArrayin interfaceTranscoder<D>- Parameters:
value- the long array- Returns:
Drepresentation oflong[]
-
getLongArray
Description copied from interface:TranscoderAttempts to unwrap along[]from the valueD- Specified by:
getLongArrayin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
getList
-
getMap
Description copied from interface:TranscoderAttempts to unwrap a map from the valueD
TheTranscoder.MapLikedecoded possibly has more ofDcontained inside.- Specified by:
getMapin interfaceTranscoder<D>- Parameters:
value- the value to unwrap- Returns:
- the result
-
createMap
Description copied from interface:TranscoderCreates aTranscoder.MapBuilder- Specified by:
createMapin interfaceTranscoder<D>- Returns:
- a new
Transcoder.MapBuilder
-
createList
Description copied from interface:TranscoderCreates aTranscoder.ListBuilder- Specified by:
createListin interfaceTranscoder<D>- Parameters:
expectedSize- the initial size- Returns:
- a list builder
-
convertTo
Description copied from interface:Transcoder- Specified by:
convertToin interfaceTranscoder<D>- 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
-