Class ChainCodec

  • All Implemented Interfaces:
    PayloadCodec

    public class ChainCodec
    extends java.lang.Object
    implements PayloadCodec
    Performs encoding/decoding on the payloads via the given codecs. When encoding, the codecs are applied last to first meaning the earlier encoders wrap the later ones. When decoding, the codecs are applied first to last to reverse the effect.
    • Constructor Summary

      Constructors 
      Constructor Description
      ChainCodec​(java.util.Collection<PayloadCodec> codecs)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<io.temporal.api.common.v1.Payload> decode​(java.util.List<io.temporal.api.common.v1.Payload> payloads)  
      java.util.List<io.temporal.api.common.v1.Payload> encode​(java.util.List<io.temporal.api.common.v1.Payload> payloads)  
      PayloadCodec withContext​(SerializationContext context)
      A correct implementation of this interface should have a fully functional "contextless" implementation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChainCodec

        public ChainCodec​(java.util.Collection<PayloadCodec> codecs)
        Parameters:
        codecs - to apply. When encoding, the codecs are applied last to first meaning the earlier encoders wrap the later ones. When decoding, the codecs are applied first to last to reverse the effect
    • Method Detail

      • encode

        @Nonnull
        public java.util.List<io.temporal.api.common.v1.Payload> encode​(@Nonnull
                                                                        java.util.List<io.temporal.api.common.v1.Payload> payloads)
        Specified by:
        encode in interface PayloadCodec
      • decode

        @Nonnull
        public java.util.List<io.temporal.api.common.v1.Payload> decode​(@Nonnull
                                                                        java.util.List<io.temporal.api.common.v1.Payload> payloads)
        Specified by:
        decode in interface PayloadCodec
      • withContext

        @Nonnull
        public PayloadCodec withContext​(@Nonnull
                                        SerializationContext context)
        Description copied from interface: PayloadCodec
        A correct implementation of this interface should have a fully functional "contextless" implementation. Temporal SDK will call this method when a knowledge of the context exists, but DataConverter can be used directly by user code and sometimes SDK itself without any context.

        Note: this method is expected to be cheap and fast. Temporal SDK doesn't always cache the instances and may be calling this method very often. Users are responsible to make sure that this method doesn't recreate expensive objects like Jackson's ObjectMapper on every call.

        Specified by:
        withContext in interface PayloadCodec
        Parameters:
        context - provides information to the data converter about the abstraction the data belongs to
        Returns:
        an instance of DataConverter that may use the provided context for serialization
        See Also:
        SerializationContext