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

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

public interface Codec<D,E,DX extends Throwable,EX extends Throwable>
A combination encoder and decoder.
Since:
4.0.0
  • Method Details

    • codec

      @NotNull static <D, E, DX extends Throwable, EX extends Throwable> @NotNull Codec<D,E,DX,EX> codec(@NotNull @NotNull Codec.Decoder<D,E,DX> decoder, @NotNull @NotNull 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.10.0
    • of

      @Deprecated @ScheduledForRemoval(inVersion="5.0.0") @NotNull static <D, E, DX extends Throwable, EX extends Throwable> @NotNull Codec<D,E,DX,EX> of(@NotNull @NotNull Codec.Decoder<D,E,DX> decoder, @NotNull @NotNull Codec.Encoder<D,E,EX> encoder)
      Deprecated.
      for removal since 4.10.0, use codec(Codec.Decoder, Codec.Encoder) instead.
      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

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

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