Interface Codec<D,​E,​DX extends Throwable,​EX extends Throwable>

Type Parameters:
D - the decoded type
E - the encoded type
DX - the exception type

public interface Codec<D,​E,​DX extends Throwable,​EX extends Throwable>
A combination encoder and decoder.
Since:
4.0.0
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Interface Description
    static interface  Codec.Decoder<D,​E,​X extends Throwable>
    A decoder.
    static interface  Codec.Encoder<D,​E,​X extends Throwable>
    An encoder.
  • Method Summary

    Modifier and Type Method Description
    @NonNull D decode​(@NonNull E encoded)
    Decodes.
    @NonNull E encode​(@NonNull D decoded)
    Encodes.
    static <D,​ E,​ DX extends Throwable,​ EX extends Throwable>
    @NonNull Codec<D,​E,​DX,​EX>
    of​(@NonNull Codec.Decoder<D,​E,​DX> decoder, @NonNull Codec.Encoder<D,​E,​EX> encoder)
    Creates a codec.
  • Method Details

    • of

      static <D,​ E,​ DX extends Throwable,​ EX extends Throwable> @NonNull Codec<D,​E,​DX,​EX> of​(@NonNull Codec.Decoder<D,​E,​DX> decoder, @NonNull Codec.Encoder<D,​E,​EX> encoder)
      Creates a codec.
      Type Parameters:
      D - the decoded type
      E - the encoded type
      DX - the decode exception type
      EX - the encode exception type
      Parameters:
      decoder - the decoder
      encoder - the encoder
      Returns:
      a codec
      Since:
      4.0.0
    • decode

      @NonNull D decode​(@NonNull E encoded) throws DX extends Throwable
      Decodes.
      Parameters:
      encoded - the encoded input
      Returns:
      the decoded value
      Throws:
      DX - if an exception is encountered while decoding
      Since:
      4.0.0
    • encode

      @NonNull E encode​(@NonNull D decoded) throws EX extends Throwable
      Encodes.
      Parameters:
      decoded - the decoded value
      Returns:
      the encoded output
      Throws:
      EX - if an exception is encountered while encoding
      Since:
      4.0.0