O - The "outer" (user-facing) Java typeI - The "inner" (Cassandra-facing, intermediary) Java typepublic abstract class MappingCodec<O,I>
extends com.datastax.driver.core.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.com.datastax.driver.core.TypeCodec.AbstractCollectionCodec<E,C extends Collection<E>>, com.datastax.driver.core.TypeCodec.AbstractMapCodec<K,V>, com.datastax.driver.core.TypeCodec.AbstractTupleCodec<T>, com.datastax.driver.core.TypeCodec.AbstractUDTCodec<T>, com.datastax.driver.core.TypeCodec.PrimitiveBooleanCodec, com.datastax.driver.core.TypeCodec.PrimitiveByteCodec, com.datastax.driver.core.TypeCodec.PrimitiveDoubleCodec, com.datastax.driver.core.TypeCodec.PrimitiveFloatCodec, com.datastax.driver.core.TypeCodec.PrimitiveIntCodec, com.datastax.driver.core.TypeCodec.PrimitiveLongCodec, com.datastax.driver.core.TypeCodec.PrimitiveShortCodec| Modifier and Type | Field and Description |
|---|---|
protected com.datastax.driver.core.TypeCodec<I> |
innerCodec |
| Constructor and Description |
|---|
MappingCodec(com.datastax.driver.core.TypeCodec<I> innerCodec,
Class<O> javaType) |
MappingCodec(com.datastax.driver.core.TypeCodec<I> innerCodec,
TypeToken<O> javaType) |
| Modifier and Type | Method and Description |
|---|---|
O |
deserialize(ByteBuffer bytes,
com.datastax.driver.core.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,
com.datastax.driver.core.ProtocolVersion protocolVersion) |
accepts, accepts, accepts, accepts, ascii, bigint, blob, cboolean, cdouble, cfloat, cint, counter, custom, date, decimal, getCqlType, getJavaType, inet, list, map, set, smallInt, time, timestamp, timeUUID, tinyInt, toString, tuple, userType, uuid, varchar, varintprotected final com.datastax.driver.core.TypeCodec<I> innerCodec
public MappingCodec(com.datastax.driver.core.TypeCodec<I> innerCodec, Class<O> javaType)
public ByteBuffer serialize(O value, com.datastax.driver.core.ProtocolVersion protocolVersion) throws com.datastax.driver.core.exceptions.InvalidTypeException
serialize in class com.datastax.driver.core.TypeCodec<O>com.datastax.driver.core.exceptions.InvalidTypeExceptionpublic O deserialize(ByteBuffer bytes, com.datastax.driver.core.ProtocolVersion protocolVersion) throws com.datastax.driver.core.exceptions.InvalidTypeException
deserialize in class com.datastax.driver.core.TypeCodec<O>com.datastax.driver.core.exceptions.InvalidTypeExceptionpublic O parse(String value) throws com.datastax.driver.core.exceptions.InvalidTypeException
parse in class com.datastax.driver.core.TypeCodec<O>com.datastax.driver.core.exceptions.InvalidTypeExceptionpublic String format(O value) throws com.datastax.driver.core.exceptions.InvalidTypeException
format in class com.datastax.driver.core.TypeCodec<O>com.datastax.driver.core.exceptions.InvalidTypeExceptionCopyright © 2012–2018. All rights reserved.