|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.document.mongodb.convert.MappingMongoConverter
public class MappingMongoConverter
MongoConverter
that uses a MappingContext
to do sophisticated mapping of domain objects to
DBObject
.
Nested Class Summary | |
---|---|
protected class |
MappingMongoConverter.PersistentPropertyWrapper
|
Field Summary | |
---|---|
protected ApplicationContext |
applicationContext
|
protected GenericConversionService |
conversionService
|
private static java.lang.String |
CUSTOM_TYPE_KEY
|
protected java.util.Map<java.lang.Class<?>,java.lang.Class<?>> |
customTypeMapping
|
protected java.lang.String |
defaultDatabase
|
protected static Log |
log
|
protected MappingContext |
mappingContext
|
protected Mongo |
mongo
|
private static java.util.List<java.lang.Class<?>> |
MONGO_TYPES
|
protected SpelExpressionParser |
spelExpressionParser
|
protected boolean |
useFieldAccessOnly
|
private static java.util.List<java.lang.Class<?>> |
VALID_ID_TYPES
|
Constructor Summary | |
---|---|
MappingMongoConverter(MappingContext mappingContext)
Creates a new MappingMongoConverter with the given MappingContext . |
Method Summary | ||
---|---|---|
void |
afterPropertiesSet()
|
|
ObjectId |
convertObjectId(java.lang.Object id)
Returns the ObjectId instance for the given id. |
|
|
convertObjectId(ObjectId id,
java.lang.Class<T> targetType)
Converts the given ObjectId to the given target type. |
|
protected DBRef |
createDBRef(java.lang.Object target,
DBRef dbref)
|
|
protected java.lang.Class<?> |
findTypeToBeUsed(DBObject dbObject)
Returns the type to be used to convert the DBObject given to. |
|
java.lang.String |
getDefaultDatabase()
|
|
MappingContext |
getMappingContext()
|
|
Mongo |
getMongo()
|
|
protected java.lang.Object |
getValueInternal(PersistentProperty prop,
DBObject dbo,
StandardEvaluationContext ctx,
Value spelExpr)
|
|
private void |
initializeConverters()
Registers converters for ObjectId handling, removes plain Object.toString() converter and promotes the
configured ConversionService to MappingBeanHelper . |
|
boolean |
isUseFieldAccessOnly()
|
|
private
|
read(
Ready from the native MongoDB DBObject representation to an instance of the class T. |
|
|
read(java.lang.Class<S> clazz,
DBObject dbo)
Ready from the native MongoDB DBObject representation to an instance of the class T. |
|
private void |
registerConverter(
Inspects the given Converter for the types it can convert and registers the pair for custom type conversion
in case the target type is a Mongo basic type. |
|
void |
setApplicationContext(ApplicationContext applicationContext)
|
|
void |
setConverters(java.util.List<
Add custom Converter or ConverterFactory instances to be used that will take presidence over
metadata driven conversion between of objects to/from DBObject |
|
void |
setDefaultDatabase(java.lang.String defaultDatabase)
|
|
void |
setMongo(Mongo mongo)
|
|
void |
setUseFieldAccessOnly(boolean useFieldAccessOnly)
|
|
void |
write(java.lang.Object obj,
DBObject dbo)
Write the given object of type T to the native MongoDB object representation DBObject. |
|
protected void |
write(java.lang.Object obj,
DBObject dbo,
|
|
protected void |
writeMapInternal(java.util.Map<java.lang.Object,java.lang.Object> obj,
DBObject dbo)
|
|
protected void |
writePropertyInternal(PersistentProperty prop,
java.lang.Object obj,
DBObject dbo)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String CUSTOM_TYPE_KEY
private static final java.util.List<java.lang.Class<?>> MONGO_TYPES
private static final java.util.List<java.lang.Class<?>> VALID_ID_TYPES
protected static final Log log
protected final GenericConversionService conversionService
protected final java.util.Map<java.lang.Class<?>,java.lang.Class<?>> customTypeMapping
protected final MappingContext mappingContext
protected SpelExpressionParser spelExpressionParser
protected ApplicationContext applicationContext
protected boolean useFieldAccessOnly
protected Mongo mongo
protected java.lang.String defaultDatabase
Constructor Detail |
---|
public MappingMongoConverter(MappingContext mappingContext)
MappingMongoConverter
with the given MappingContext
.
mappingContext
- Method Detail |
---|
public void setConverters(java.util.List<> converters)
Converter
or ConverterFactory
instances to be used that will take presidence over
metadata driven conversion between of objects to/from DBObject
converters
- private void registerConverter(converter)
Converter
for the types it can convert and registers the pair for custom type conversion
in case the target type is a Mongo basic type.
converter
- public MappingContext getMappingContext()
public Mongo getMongo()
public void setMongo(Mongo mongo)
public java.lang.String getDefaultDatabase()
public void setDefaultDatabase(java.lang.String defaultDatabase)
public boolean isUseFieldAccessOnly()
public void setUseFieldAccessOnly(boolean useFieldAccessOnly)
public <T> T convertObjectId(ObjectId id, java.lang.Class<T> targetType)
MongoConverter
ObjectId
to the given target type.
convertObjectId
in interface MongoConverter
T
- the actual type to createid
- the source ObjectId
targetType
- the target type to convert the ObjectId
to
public ObjectId convertObjectId(java.lang.Object id)
MongoConverter
ObjectId
instance for the given id.
convertObjectId
in interface MongoConverter
public <S> S read(java.lang.Class<S> clazz, DBObject dbo)
MongoReader
DBObject
into it. So in case there's no real valid data inside
DBObject
for the given type, just return an empty instance of the given type.
read
in interface MongoReader<java.lang.Object>
clazz
- the type of the return valuedbo
- theDBObject
private <S> S read(entity, DBObject dbo)
MongoReader
DBObject
into it. So in case there's no real valid data inside
DBObject
for the given type, just return an empty instance of the given type.
read
in interface MongoReader<java.lang.Object>
entity
- the type of the return valuedbo
- theDBObject
public void write(java.lang.Object obj, DBObject dbo)
MongoWriter
write
in interface MongoWriter<java.lang.Object>
obj
- The object to convert to a DBObjectdbo
- The DBObject to use for writing.protected void write(java.lang.Object obj, DBObject dbo,entity)
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
BeansException
private void initializeConverters()
ObjectId
handling, removes plain Object.toString()
converter and promotes the
configured ConversionService
to MappingBeanHelper
.
protected void writePropertyInternal(PersistentProperty prop, java.lang.Object obj, DBObject dbo)
protected void writeMapInternal(java.util.Map<java.lang.Object,java.lang.Object> obj, DBObject dbo)
protected DBRef createDBRef(java.lang.Object target, DBRef dbref)
protected java.lang.Object getValueInternal(PersistentProperty prop, DBObject dbo, StandardEvaluationContext ctx, Value spelExpr)
protected java.lang.Class<?> findTypeToBeUsed(DBObject dbObject)
dbObject
-
public void afterPropertiesSet()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |