O - The "outer" (user-facing) Java typeI - The "inner" (Cassandra-facing, intermediary) Java typepublic abstract class MappingCodec<O,I> extends TypeCodec<O>
TypeCodec that maps a Java Pojo to another Java object
that can in turn be serialized into a CQL type.
This can serve as a base for libraries dealing with Pojo mappings.
This codec can be seen as a convenience base class for libraries
dealing with Pojo-to-Pojo mappings, but it comes
with a performance penalty: each Java object is serialized
in two steps: first to an intermediate object, and then to a ByteBuffer,
which means that each serialization actually incurs in two potentially
expensive operations being carried.
If such operations are really expensive, and your mapping library is capable
of serializing objects directly to ByteBuffers,
consider writing your own codec instead of using this one.TypeCodec.AbstractCollectionCodec<E,C extends Collection<E>>, TypeCodec.AbstractMapCodec<K,V>, TypeCodec.AbstractTupleCodec<T>, TypeCodec.AbstractUDTCodec<T>, TypeCodec.PrimitiveBooleanCodec, TypeCodec.PrimitiveByteCodec, TypeCodec.PrimitiveDoubleCodec, TypeCodec.PrimitiveFloatCodec, TypeCodec.PrimitiveIntCodec, TypeCodec.PrimitiveLongCodec, TypeCodec.PrimitiveShortCodec| Modifier and Type | Field and Description |
|---|---|
protected TypeCodec<I> |
innerCodec |
| Constructor and Description |
|---|
MappingCodec(TypeCodec<I> innerCodec,
Class<O> javaType) |
MappingCodec(TypeCodec<I> innerCodec,
TypeToken<O> javaType) |
| Modifier and Type | Method and Description |
|---|---|
O |
deserialize(ByteBuffer bytes,
ProtocolVersion protocolVersion) |
protected abstract O |
deserialize(I value) |
String |
format(O value) |
O |
parse(String value) |
protected abstract I |
serialize(O value) |
ByteBuffer |
serialize(O value,
ProtocolVersion protocolVersion) |
accepts, accepts, accepts, accepts, ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, duration, getCqlType, getJavaType, inet, list, map, set, smallInt, time, timestamp, timeUUID, tinyInt, toString, tuple, userType, uuid, varchar, varintpublic ByteBuffer serialize(O value, ProtocolVersion protocolVersion) throws InvalidTypeException
serialize in class TypeCodec<O>InvalidTypeExceptionpublic O deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException
deserialize in class TypeCodec<O>InvalidTypeExceptionpublic O parse(String value) throws InvalidTypeException
parse in class TypeCodec<O>InvalidTypeExceptionpublic String format(O value) throws InvalidTypeException
format in class TypeCodec<O>InvalidTypeExceptionCopyright © 2012–2017. All rights reserved.