public class MappingCouchbaseConverter extends AbstractCouchbaseConverter implements ApplicationContextAware
| Modifier and Type | Field and Description |
|---|---|
protected ApplicationContext |
applicationContext
The overall application context.
|
protected MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> |
mappingContext
The generic mapping context.
|
static String |
TYPEKEY_DEFAULT
The default "type key", the name of the field that will hold type information.
|
static String |
TYPEKEY_SYNCGATEWAY_COMPATIBLE
A "type key" (the name of the field that will hold type information) that is compatible with Sync Gateway (which
doesn't allows underscores).
|
protected CouchbaseTypeMapper |
typeMapper
The Couchbase specific type mapper in use.
|
conversions, conversionService, instantiators| Constructor and Description |
|---|
MappingCouchbaseConverter() |
MappingCouchbaseConverter(MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext)
Create a new
MappingCouchbaseConverter. |
MappingCouchbaseConverter(MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext,
String typeKey)
Create a new
MappingCouchbaseConverter that will store class name for complex types in the typeKey
attribute. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addCustomTypeKeyIfNecessary(TypeInformation<?> type,
Object source,
CouchbaseDocument target)
Add a custom type key if needed.
|
protected void |
copyCouchbaseDocument(CouchbaseDocument source,
CouchbaseDocument target)
Helper method to copy the internals from a source document into a target document.
|
MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> |
getMappingContext() |
Object |
getPotentiallyConvertedSimpleWrite(Object value) |
Alias |
getTypeAlias(TypeInformation<?> info) |
String |
getTypeKey() |
protected Object |
getValueInternal(CouchbasePersistentProperty property,
CouchbaseDocument source,
Object parent,
PersistentEntity entity)
Loads the property value through the value provider.
|
<R> R |
read(Class<R> clazz,
CouchbaseDocument source) |
protected <R> R |
read(CouchbasePersistentEntity<R> entity,
CouchbaseDocument source,
Object parent)
Read an incoming
CouchbaseDocument into the target entity. |
protected <R> R |
read(TypeInformation<R> type,
CouchbaseDocument source)
Read an incoming
CouchbaseDocument into the target entity. |
protected <R> R |
read(TypeInformation<R> type,
CouchbaseDocument source,
Object parent)
Read an incoming
CouchbaseDocument into the target entity. |
protected Map<Object,Object> |
readMap(TypeInformation<?> type,
CouchbaseDocument source,
Object parent)
Recursively parses the a map from the source document.
|
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setEntityCallbacks(EntityCallbacks entityCallbacks)
COPIED Set the
EntityCallbacks instance to use when invoking
callbacks like the AfterConvertCallback. |
void |
write(Object source,
CouchbaseDocument target) |
protected void |
writeInternal(Object source,
CouchbaseDocument target,
CouchbasePersistentEntity<?> entity,
boolean withId)
Internal helper method to write the source object into the target document.
|
protected void |
writeInternal(Object source,
CouchbaseDocument target,
TypeInformation<?> typeHint,
boolean withId)
Convert a source object into a
CouchbaseDocument target. |
afterPropertiesSet, convertForWriteIfNeeded, getConversionService, getWriteClassFor, setCustomConversions, setInstantiatorspublic static final String TYPEKEY_DEFAULT
public static final String TYPEKEY_SYNCGATEWAY_COMPATIBLE
protected final MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext
protected ApplicationContext applicationContext
protected CouchbaseTypeMapper typeMapper
public MappingCouchbaseConverter()
public MappingCouchbaseConverter(MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext)
MappingCouchbaseConverter.mappingContext - the mapping context to use.public MappingCouchbaseConverter(MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext, String typeKey)
MappingCouchbaseConverter that will store class name for complex types in the typeKey
attribute.mappingContext - the mapping context to use.typeKey - the attribute name to use to store complex types class name.public MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> getMappingContext()
getMappingContext in interface EntityConverter<CouchbasePersistentEntity<?>,CouchbasePersistentProperty,Object,CouchbaseDocument>public String getTypeKey()
getTypeKey in interface CouchbaseConverterpublic Alias getTypeAlias(TypeInformation<?> info)
getTypeAlias in interface CouchbaseConverterpublic <R> R read(Class<R> clazz, CouchbaseDocument source)
read in interface EntityReader<Object,CouchbaseDocument>protected <R> R read(TypeInformation<R> type, CouchbaseDocument source)
CouchbaseDocument into the target entity.R - the entity type.type - the type information of the target entity.source - the document to convert.protected <R> R read(TypeInformation<R> type, CouchbaseDocument source, Object parent)
CouchbaseDocument into the target entity.R - the entity type.type - the type information of the target entity.source - the document to convert.parent - an optional parent object.protected <R> R read(CouchbasePersistentEntity<R> entity, CouchbaseDocument source, Object parent)
CouchbaseDocument into the target entity.R - the entity type.entity - the target entity.source - the document to convert.parent - an optional parent object.protected Object getValueInternal(CouchbasePersistentProperty property, CouchbaseDocument source, Object parent, PersistentEntity entity)
property - the source property.source - the source document.parent - the optional parent.protected Map<Object,Object> readMap(TypeInformation<?> type, CouchbaseDocument source, Object parent)
type - the type information for the document.source - the source document.parent - the optional parent.public void write(Object source, CouchbaseDocument target)
write in interface EntityWriter<Object,CouchbaseDocument>protected void writeInternal(Object source, CouchbaseDocument target, TypeInformation<?> typeHint, boolean withId)
CouchbaseDocument target.source - the source object.target - the target document.typeHint - the type information for the source.protected void copyCouchbaseDocument(CouchbaseDocument source, CouchbaseDocument target)
source - the source document.target - the target document.protected void writeInternal(Object source, CouchbaseDocument target, CouchbasePersistentEntity<?> entity, boolean withId)
source - the source object.target - the target document.entity - the persistent entity to convert from.withId - one of the top-level properties is the id for the documentprotected void addCustomTypeKeyIfNecessary(TypeInformation<?> type, Object source, CouchbaseDocument target)
type - the type information.source - th the source object.target - the target document.public void setApplicationContext(ApplicationContext applicationContext)
setApplicationContext in interface ApplicationContextAwarepublic void setEntityCallbacks(EntityCallbacks entityCallbacks)
EntityCallbacks instance to use when invoking
callbacks like the AfterConvertCallback.
Overrides potentially existing EntityCallbacks.entityCallbacks - must not be null.IllegalArgumentException - if the given instance is null.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.