Spring Data MongoDB - Core

org.springframework.data.mongodb.core.convert
Class UpdateMapper

java.lang.Object
  extended by org.springframework.data.mongodb.core.convert.QueryMapper
      extended by org.springframework.data.mongodb.core.convert.UpdateMapper

public class UpdateMapper
extends QueryMapper

A subclass of QueryMapper that retains type information on the mongo types.

Author:
Thomas Darimont, Oliver Gierke, Christoph Strobl

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.data.mongodb.core.convert.QueryMapper
QueryMapper.Field, QueryMapper.MetadataBackedField
 
Constructor Summary
UpdateMapper(MongoConverter converter)
          Creates a new UpdateMapper using the given MongoConverter.
 
Method Summary
protected  QueryMapper.Field createPropertyField(MongoPersistentEntity<?> entity, String key, MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext)
           
protected  Object delegateConvertToMongoType(Object source, MongoPersistentEntity<?> entity)
          Converts the given source object to a mongo type retaining the original type information of the source type on the mongo type.
protected  Map.Entry<String,Object> getMappedObjectForField(QueryMapper.Field field, Object rawValue)
          Extracts the mapped object value for given field out of rawValue taking nested Keywords into account
protected  boolean isAssociationConversionNecessary(QueryMapper.Field documentField, Object value)
          Returns whether the given QueryMapper.Field represents an association reference that together with the given value requires conversion to a DBRef object.
 
Methods inherited from class org.springframework.data.mongodb.core.convert.QueryMapper
convertAssociation, convertAssociation, convertId, getMappedKeyword, getMappedKeyword, getMappedObject, getMappedValue, isKeyword, isNestedKeyword
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdateMapper

public UpdateMapper(MongoConverter converter)
Creates a new UpdateMapper using the given MongoConverter.

Parameters:
converter - must not be null.
Method Detail

delegateConvertToMongoType

protected Object delegateConvertToMongoType(Object source,
                                            MongoPersistentEntity<?> entity)
Converts the given source object to a mongo type retaining the original type information of the source type on the mongo type.

Overrides:
delegateConvertToMongoType in class QueryMapper
Returns:
the converted mongo type or null if source is null
See Also:
QueryMapper.delegateConvertToMongoType(java.lang.Object, org.springframework.data.mongodb.core.mapping.MongoPersistentEntity)

getMappedObjectForField

protected Map.Entry<String,Object> getMappedObjectForField(QueryMapper.Field field,
                                                           Object rawValue)
Description copied from class: QueryMapper
Extracts the mapped object value for given field out of rawValue taking nested Keywords into account

Overrides:
getMappedObjectForField in class QueryMapper
Returns:

isAssociationConversionNecessary

protected boolean isAssociationConversionNecessary(QueryMapper.Field documentField,
                                                   Object value)
Description copied from class: QueryMapper
Returns whether the given QueryMapper.Field represents an association reference that together with the given value requires conversion to a DBRef object. We check whether the type of the given value is compatible with the type of the given document field in order to deal with potential query field exclusions, since MongoDB uses the int 0 as an indicator for an excluded field.

Overrides:
isAssociationConversionNecessary in class QueryMapper
Returns:

createPropertyField

protected QueryMapper.Field createPropertyField(MongoPersistentEntity<?> entity,
                                                String key,
                                                MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext)
Overrides:
createPropertyField in class QueryMapper
Returns:

Spring Data MongoDB - Core

Copyright © 2011-2013-2014 Pivotal. All Rights Reserved.