Interface Transcoder<D>

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 Transcoder types. They are also responsible for unwrapping these objects back to their primitives.
Commonly used transcoders are accessible through static fields like JSON
  • Field Details

  • Method Details

    • createNull

      D createNull()
      Creates a null representation of Transcoder
      Returns:
      the null object, never null
    • getBoolean

      Result<Boolean> getBoolean(D value)
      Attempts to unwrap a boolean from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createBoolean

      D createBoolean(boolean value)
      Creates a boolean representation of Transcoder
      Parameters:
      value - the boolean primitive
      Returns:
      the representation of value in Transcoder
    • getByte

      Result<Byte> getByte(D value)
      Attempts to unwrap a byte from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createByte

      D createByte(byte value)
      Creates a byte representation of Transcoder
      Parameters:
      value - the byte primitive
      Returns:
      the representation of value in Transcoder
    • getShort

      Result<Short> getShort(D value)
      Attempts to unwrap a short from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createShort

      D createShort(short value)
      Creates a short representation of Transcoder
      Parameters:
      value - the short primitive
      Returns:
      the representation of value in Transcoder
    • getInt

      Result<Integer> getInt(D value)
      Attempts to unwrap an int from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createInt

      D createInt(int value)
      Creates an int representation of Transcoder
      Parameters:
      value - the int primitive
      Returns:
      the representation of value in Transcoder
    • getLong

      Result<Long> getLong(D value)
      Attempts to unwrap a long from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createLong

      D createLong(long value)
      Creates a long representation of Transcoder
      Parameters:
      value - the long primitive
      Returns:
      the representation of value in Transcoder
    • getFloat

      Result<Float> getFloat(D value)
      Attempts to unwrap a float from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createFloat

      D createFloat(float value)
      Creates a float representation of Transcoder
      Parameters:
      value - the float primitive
      Returns:
      the representation of value in Transcoder
    • getDouble

      Result<Double> getDouble(D value)
      Attempts to unwrap a double from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createDouble

      D createDouble(double value)
      Creates a float representation of Transcoder
      Parameters:
      value - the float primitive
      Returns:
      the representation of value in Transcoder
    • getString

      Result<String> getString(D value)
      Attempts to unwrap a string from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createString

      D createString(String value)
      Creates a string representation of Transcoder
      Parameters:
      value - the string primitive
      Returns:
      the representation of value in Transcoder
    • getList

      Result<@Unmodifiable List<D>> getList(D value)
      Attempts to unwrap a list from the value Transcoder
      The List decoded possibly has more of Transcoder contained inside.
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • emptyList

      default D emptyList()
      A empty list intermediary
      Returns:
      the empty list intermediary
    • createList

      @Contract(pure=true) Transcoder.ListBuilder<D> createList(int expectedSize)
      Parameters:
      expectedSize - the initial size
      Returns:
      a list builder
    • getMap

      Result<Transcoder.MapLike<D>> getMap(D value)
      Attempts to unwrap a map from the value Transcoder
      The Transcoder.MapLike decoded possibly has more of Transcoder contained inside.
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • emptyMap

      default D emptyMap()
      A emtpy map intermediary
      Returns:
      the empty map intermediary
    • createMap

      Returns:
      a new Transcoder.MapBuilder
    • getByteArray

      default Result<byte[]> getByteArray(D value)
      Attempts to unwrap a byte[] from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createByteArray

      default D createByteArray(byte[] value)
      Creates a byte[] representation of Transcoder
      Parameters:
      value - the byte array
      Returns:
      Transcoder representation of byte[]
    • getIntArray

      default Result<int[]> getIntArray(D value)
      Attempts to unwrap a int[] from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createIntArray

      default D createIntArray(int[] value)
      Creates a int[] representation of Transcoder
      Parameters:
      value - the int array
      Returns:
      Transcoder representation of int[]
    • getLongArray

      default Result<long[]> getLongArray(D value)
      Attempts to unwrap a long[] from the value Transcoder
      Parameters:
      value - the value to unwrap
      Returns:
      the result
    • createLongArray

      default D createLongArray(long[] value)
      Creates a long[] representation of Transcoder
      Parameters:
      value - the long array
      Returns:
      Transcoder representation of long[]
    • convertTo

      <O> Result<O> convertTo(Transcoder<O> coder, D value)
      Converts the current intermediary of Transcoder into intermediary Transcoder
      Type Parameters:
      O - the intermediary type to convert to
      Parameters:
      coder - the transcoder to convert to
      value - the value to convert
      Returns:
      the resultant of the conversion