Interface Codec<A,B>

All Known Implementing Classes:
ByteArraysCodec, Codec.FunctionalCodec, Codec.NullPassthroughCodec

public interface Codec<A,B>
A bi-directional Function where encoding then decoding should typically return the original value.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Build a Codec from two Functions.
    static class 
    Skips the inner codecs when provided values are null, directly returning null.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Codec<?,?>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(B encodedValue)
     
    encode(A value)
     
    default A
    Useful for testing
    static <A> Codec<A,A>
    Use Codec.identity() when you must supply a Codec but don't need to encode anything.
    static <A, B> Codec<A,B>
    of(Function<A,B> encodeFunction, Function<B,A> decodeFunction)
     
  • Field Details

    • IDENTITY_INSTANCE

      static final Codec<?,?> IDENTITY_INSTANCE
  • Method Details

    • encode

      B encode(A value)
    • decode

      A decode(B encodedValue)
    • encodeAndDecode

      default A encodeAndDecode(A value)
      Useful for testing
    • of

      static <A, B> Codec<A,B> of(Function<A,B> encodeFunction, Function<B,A> decodeFunction)
    • identity

      static <A> Codec<A,A> identity()
      Use Codec.identity() when you must supply a Codec but don't need to encode anything.