Class DelegateCodec<T>

java.lang.Object
io.airlift.drift.codec.DelegateCodec<T>
All Implemented Interfaces:
ThriftCodec<T>

public class DelegateCodec<T> extends Object implements ThriftCodec<T>
A placeholder for aThriftCodec that defers computation of the real codec until it is actually used, and then just delegates to that codec.

This is used to break the cycle when computing the codec for a recursive type tries to compute codecs for all of its fields.

  • Constructor Details

  • Method Details

    • getType

      public ThriftType getType()
      Description copied from interface: ThriftCodec
      The Thrift type this codec supports. The Thrift type contains the Java generic Type of the codec.
      Specified by:
      getType in interface ThriftCodec<T>
    • read

      public T read(TProtocolReader protocol) throws Exception
      Description copied from interface: ThriftCodec
      Reads a value from supplied Thrift protocol reader.
      Specified by:
      read in interface ThriftCodec<T>
      Parameters:
      protocol - the protocol to read from
      Returns:
      the value; not null
      Throws:
      Exception - if any problems occurred when reading or coercing the value
    • write

      public void write(T value, TProtocolWriter protocol) throws Exception
      Description copied from interface: ThriftCodec
      Writes a value to the supplied Thrift protocol writer.
      Specified by:
      write in interface ThriftCodec<T>
      Parameters:
      value - the value to write; not null
      protocol - the protocol to write to
      Throws:
      Exception - if any problems occurred when writing or coercing the value