public class MappingCouchbaseConverter extends AbstractCouchbaseConverter implements ApplicationContextAware
| Modifier and Type | Field and Description |
|---|---|
protected ApplicationContext |
applicationContext
The overall application context.
|
protected org.springframework.data.mapping.context.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(org.springframework.data.mapping.context.MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext)
Create a new
MappingCouchbaseConverter. |
MappingCouchbaseConverter(org.springframework.data.mapping.context.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(org.springframework.data.util.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.
|
org.springframework.data.mapping.context.MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> |
getMappingContext() |
Object |
getPotentiallyConvertedSimpleWrite(Object value) |
org.springframework.data.mapping.Alias |
getTypeAlias(org.springframework.data.util.TypeInformation<?> info) |
String |
getTypeKey() |
protected Object |
getValueInternal(CouchbasePersistentProperty property,
CouchbaseDocument source,
Object parent,
org.springframework.data.mapping.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(org.springframework.data.util.TypeInformation<R> type,
CouchbaseDocument source)
Read an incoming
CouchbaseDocument into the target entity. |
protected <R> R |
read(org.springframework.data.util.TypeInformation<R> type,
CouchbaseDocument source,
Object parent)
Read an incoming
CouchbaseDocument into the target entity. |
protected Map<Object,Object> |
readMap(org.springframework.data.util.TypeInformation<?> type,
CouchbaseDocument source,
Object parent)
Recursively parses the a map from the source document.
|
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setEntityCallbacks(org.springframework.data.mapping.callback.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,
org.springframework.data.util.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 org.springframework.data.mapping.context.MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext
protected ApplicationContext applicationContext
protected CouchbaseTypeMapper typeMapper
public MappingCouchbaseConverter()
public MappingCouchbaseConverter(org.springframework.data.mapping.context.MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> mappingContext)
MappingCouchbaseConverter.mappingContext - the mapping context to use.public MappingCouchbaseConverter(org.springframework.data.mapping.context.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 org.springframework.data.mapping.context.MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> getMappingContext()
getMappingContext in interface org.springframework.data.convert.EntityConverter<CouchbasePersistentEntity<?>,CouchbasePersistentProperty,Object,CouchbaseDocument>public String getTypeKey()
getTypeKey in interface CouchbaseConverterpublic org.springframework.data.mapping.Alias getTypeAlias(org.springframework.data.util.TypeInformation<?> info)
getTypeAlias in interface CouchbaseConverterpublic <R> R read(Class<R> clazz, CouchbaseDocument source)
read in interface org.springframework.data.convert.EntityReader<Object,CouchbaseDocument>protected <R> R read(org.springframework.data.util.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(org.springframework.data.util.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, org.springframework.data.mapping.PersistentEntity entity)
property - the source property.source - the source document.parent - the optional parent.protected Map<Object,Object> readMap(org.springframework.data.util.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 org.springframework.data.convert.EntityWriter<Object,CouchbaseDocument>protected void writeInternal(Object source, CouchbaseDocument target, org.springframework.data.util.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(org.springframework.data.util.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(org.springframework.data.mapping.callback.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–2023 Pivotal Software, Inc.. All rights reserved.