Class EnumThriftCodec<T extends Enum<T>>

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

@Immutable public class EnumThriftCodec<T extends Enum<T>> extends Object implements ThriftCodec<T>
EnumThriftCodec is a codec for Java enum types. An enum is encoded as an I32 in Thrift, and this class handles converting this vale to a Java enum constant.
  • Constructor Details

    • EnumThriftCodec

      public EnumThriftCodec(ThriftType type)
  • 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 extends Enum<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 extends Enum<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 enumConstant, 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 extends Enum<T>>
      Parameters:
      enumConstant - the value to write; not null
      protocol - the protocol to write to
      Throws:
      Exception - if any problems occurred when writing or coercing the value