Package io.airlift.drift.codec
Interface ThriftCodec<T>
- Type Parameters:
T- the type this codec supports
- All Known Implementing Classes:
AbstractReflectionThriftCodec,BooleanArrayThriftCodec,BooleanThriftCodec,ByteBufferThriftCodec,ByteThriftCodec,CoercionThriftCodec,DelegateCodec,DoubleArrayThriftCodec,DoubleThriftCodec,EnumThriftCodec,IntArrayThriftCodec,IntegerThriftCodec,ListThriftCodec,LongArrayThriftCodec,LongThriftCodec,MapThriftCodec,OptionalDoubleThriftCodec,OptionalIntThriftCodec,OptionalLongThriftCodec,OptionalThriftCodec,ReflectionThriftStructCodec,ReflectionThriftUnionCodec,SetThriftCodec,ShortArrayThriftCodec,ShortThriftCodec,StringThriftCodec,VoidThriftCodec
public interface ThriftCodec<T>
A single type codec for reading and writing in Thrift format. Each codec is symmetric and therefore only supports a single concrete type.
Implementations of this interface are expected to be thread safe.
-
Method Summary
Modifier and TypeMethodDescriptiongetType()The Thrift type this codec supports.default booleanIf the value is effectively null and should not be written.read(TProtocolReader protocol) Reads a value from supplied Thrift protocol reader.voidwrite(T value, TProtocolWriter protocol) Writes a value to the supplied Thrift protocol writer.
-
Method Details
-
getType
ThriftType getType()The Thrift type this codec supports. The Thrift type contains the Java generic Type of the codec. -
read
Reads a value from supplied Thrift protocol reader.- 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
Writes a value to the supplied Thrift protocol writer.- Parameters:
value- the value to write; not nullprotocol- the protocol to write to- Throws:
Exception- if any problems occurred when writing or coercing the value
-
isNull
If the value is effectively null and should not be written.- Parameters:
value- the value to test- Returns:
- true if the value should not be written
-