public class MappingCassandraConverter extends AbstractCassandraConverter implements ApplicationContextAware, BeanClassLoaderAware
Modifier and Type | Class and Description |
---|---|
protected static class |
MappingCassandraConverter.ConversionContext
Conversion context holding references to simple
ValueConverter and ContainerValueConverter . |
Constructor and Description |
---|
MappingCassandraConverter()
Create a new
MappingCassandraConverter with a CassandraMappingContext . |
MappingCassandraConverter(CassandraMappingContext mappingContext)
Create a new
MappingCassandraConverter with the given CassandraMappingContext . |
Modifier and Type | Method and Description |
---|---|
Object |
convertToColumnType(Object obj)
Converts the given object into a value Cassandra will be able to store natively in a column.
|
Object |
convertToColumnType(Object value,
ColumnType columnType)
Converts the given object into a value Cassandra will be able to store natively in a column.
|
protected <S> S |
doReadEntity(MappingCassandraConverter.ConversionContext context,
CassandraValueProvider valueProvider,
TypeInformation<? extends S> typeHint)
Conversion method to materialize an object from a
Row , TupleValue , or UdtValue . |
com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry |
getCodecRegistry()
Returns the configured
CodecRegistry . |
ColumnTypeResolver |
getColumnTypeResolver()
|
protected MappingCassandraConverter.ConversionContext |
getConversionContext()
Creates a new
MappingCassandraConverter.ConversionContext . |
Object |
getId(Object object,
CassandraPersistentEntity<?> entity)
Returns the Id for an entity.
|
CassandraMappingContext |
getMappingContext() |
protected Object |
getPotentiallyConvertedSimpleRead(Object value,
TypeInformation<?> target)
Checks whether we have a custom conversion for the given simple object.
|
UserTypeResolver |
getUserTypeResolver()
Returns the configured
UserTypeResolver . |
<R> R |
read(Class<R> type,
Object row) |
protected Object |
readCollectionOrArray(MappingCassandraConverter.ConversionContext context,
Collection<?> source,
TypeInformation<?> targetType)
Reads the given
Collection into a collection of the given TypeInformation . |
protected Object |
readMap(MappingCassandraConverter.ConversionContext context,
Map<?,?> source,
TypeInformation<?> targetType)
Reads the given
Map into a map of the given TypeInformation . |
<R> R |
readRow(Class<R> type,
com.datastax.oss.driver.api.core.cql.Row row)
Read a
Row into the requested target type . |
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setCodecRegistry(com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry codecRegistry)
Sets the
CodecRegistry . |
void |
setUserTypeResolver(UserTypeResolver userTypeResolver)
Sets the
UserTypeResolver . |
void |
write(Object source,
Object sink) |
void |
write(Object source,
Object sink,
CassandraPersistentEntity<?> entity)
|
afterPropertiesSet, getConversionService, getCustomConversions, setCustomConversions, setInstantiators
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertToColumnType
public MappingCassandraConverter()
MappingCassandraConverter
with a CassandraMappingContext
.public MappingCassandraConverter(CassandraMappingContext mappingContext)
MappingCassandraConverter
with the given CassandraMappingContext
.mappingContext
- must not be null.protected MappingCassandraConverter.ConversionContext getConversionContext()
MappingCassandraConverter.ConversionContext
.MappingCassandraConverter.ConversionContext
.public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
public void setCodecRegistry(com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry codecRegistry)
CodecRegistry
.codecRegistry
- must not be null.public com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry getCodecRegistry()
CodecRegistry
.getCodecRegistry
in interface CassandraConverter
CodecRegistry
.public void setUserTypeResolver(UserTypeResolver userTypeResolver)
UserTypeResolver
.userTypeResolver
- must not be null.public UserTypeResolver getUserTypeResolver()
UserTypeResolver
.UserTypeResolver
.public CassandraMappingContext getMappingContext()
getMappingContext
in interface CassandraConverter
getMappingContext
in interface EntityConverter<CassandraPersistentEntity<?>,CassandraPersistentProperty,Object,Object>
public ColumnTypeResolver getColumnTypeResolver()
CassandraConverter
getColumnTypeResolver
in interface CassandraConverter
ColumnTypeResolver
public <R> R read(Class<R> type, Object row)
read
in interface EntityReader<Object,Object>
public <R> R readRow(Class<R> type, com.datastax.oss.driver.api.core.cql.Row row)
Row
into the requested target type
.type
- must not be null.row
- must not be null.protected <S> S doReadEntity(MappingCassandraConverter.ConversionContext context, CassandraValueProvider valueProvider, TypeInformation<? extends S> typeHint)
Row
, TupleValue
, or UdtValue
. Can be
overridden by subclasses.context
- must not be nullvalueProvider
- must not be nulltypeHint
- the TypeInformation
to be used to unmarshall this Row
.public Object convertToColumnType(Object obj)
CassandraConverter
convertToColumnType
in interface CassandraConverter
obj
- Object
to convert; must not be null.public Object convertToColumnType(Object value, ColumnType columnType)
CassandraConverter
convertToColumnType
in interface CassandraConverter
value
- Object
to convert; must not be null.columnType
- ColumnType
used to describe the object type; must not be null.public void write(Object source, Object sink)
write
in interface EntityWriter<Object,Object>
public void write(Object source, Object sink, CassandraPersistentEntity<?> entity)
CassandraConverter
write
in interface CassandraConverter
source
- the source, must not be null.sink
- must not be null.entity
- must not be null.public Object getId(Object object, CassandraPersistentEntity<?> entity)
CassandraConverter
Id
or
PrimaryKey
IdMapId
for composite PrimaryKeyColumn
Id'sPrimaryKey
using a
PrimaryKeyClass
getId
in interface CassandraConverter
object
- must not be null.entity
- must not be null.protected Object getPotentiallyConvertedSimpleRead(Object value, TypeInformation<?> target)
Enum
handling or returns the value as is. Can be overridden by subclasses.protected Object readCollectionOrArray(MappingCassandraConverter.ConversionContext context, Collection<?> source, TypeInformation<?> targetType)
Collection
into a collection of the given TypeInformation
. Will recursively resolve
nested List
s as well. Can be overridden by subclasses.source
- must not be null.targetType
- must not be null.Collection
or array, will never be null.protected Object readMap(MappingCassandraConverter.ConversionContext context, Map<?,?> source, TypeInformation<?> targetType)
Map
into a map of the given TypeInformation
. Will recursively resolve nested
Map
s as well. Can be overridden by subclasses.source
- must not be null.targetType
- must not be null.Collection
or array, will never be null.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.