Package net.kyori.adventure.util
Interface Codec<D,E,DX extends Throwable,EX extends Throwable>
- Type Parameters:
D
- the decoded typeE
- the encoded typeDX
- 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 typeE
- the encoded typeDX
- the decode exception typeEX
- the encode exception type- Parameters:
decoder
- the decoderencoder
- the encoder- Returns:
- a codec
- Since:
- 4.0.0
-
decode
Decodes.- Parameters:
encoded
- the encoded input- Returns:
- the decoded value
- Throws:
DX
- if an exception is encountered while decoding- Since:
- 4.0.0
-
encode
Encodes.- Parameters:
decoded
- the decoded value- Returns:
- the encoded output
- Throws:
EX
- if an exception is encountered while encoding- Since:
- 4.0.0
-