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  Codec.FunctionalCodec<A,​B>
    Build a Codec from two Functions.
    static class  Codec.NullPassthroughCodec<A,​B>
    Skips the inner codecs when provided values are null, directly returning null.
  • Method Summary

    Modifier and Type Method Description
    A decode​(B encodedValue)  
    B encode​(A value)  
    default A encodeAndDecode​(A value)
    Useful for testing
    static <A,​ B> Codec<A,​B> of​(Function<A,​B> encodeFunction, Function<B,​A> decodeFunction)  
  • 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)