Spring Data MongoDB - Core

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

java.lang.Object
  extended by org.springframework.data.convert.DefaultTypeMapper<com.mongodb.DBObject>
      extended by org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper
All Implemented Interfaces:
TypeMapper<com.mongodb.DBObject>, MongoTypeMapper

public class DefaultMongoTypeMapper
extends DefaultTypeMapper<com.mongodb.DBObject>
implements MongoTypeMapper

Default implementation of MongoTypeMapper allowing configuration of the key to lookup and store type information in DBObject. The key defaults to DEFAULT_TYPE_KEY. Actual type-to-String conversion and back is done in #getTypeString(TypeInformation) or #getTypeInformation(String) respectively.

Author:
Oliver Gierke, Thomas Darimont

Nested Class Summary
static class DefaultMongoTypeMapper.DBObjectTypeAliasAccessor
          TypeAliasAccessor to store aliases in a DBObject.
 
Field Summary
static String DEFAULT_TYPE_KEY
           
 
Constructor Summary
DefaultMongoTypeMapper()
           
DefaultMongoTypeMapper(String typeKey)
           
DefaultMongoTypeMapper(String typeKey, List<? extends TypeInformationMapper> mappers)
           
DefaultMongoTypeMapper(String typeKey, MappingContext<? extends PersistentEntity<?,?>,?> mappingContext)
           
 
Method Summary
protected  TypeInformation<?> getFallbackTypeFor(com.mongodb.DBObject source)
           
 boolean isTypeKey(String key)
          Returns whether the given key is the type key.
 void writeTypeRestrictions(com.mongodb.DBObject result, Set<Class<?>> restrictedTypes)
          Writes type restrictions to the given DBObject.
 
Methods inherited from class org.springframework.data.convert.DefaultTypeMapper
getAliasFor, readType, readType, writeType, writeType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.data.convert.TypeMapper
readType, readType, writeType, writeType
 

Field Detail

DEFAULT_TYPE_KEY

public static final String DEFAULT_TYPE_KEY
See Also:
Constant Field Values
Constructor Detail

DefaultMongoTypeMapper

public DefaultMongoTypeMapper()

DefaultMongoTypeMapper

public DefaultMongoTypeMapper(String typeKey)

DefaultMongoTypeMapper

public DefaultMongoTypeMapper(String typeKey,
                              MappingContext<? extends PersistentEntity<?,?>,?> mappingContext)

DefaultMongoTypeMapper

public DefaultMongoTypeMapper(String typeKey,
                              List<? extends TypeInformationMapper> mappers)
Method Detail

isTypeKey

public boolean isTypeKey(String key)
Description copied from interface: MongoTypeMapper
Returns whether the given key is the type key.

Specified by:
isTypeKey in interface MongoTypeMapper
Returns:

writeTypeRestrictions

public void writeTypeRestrictions(com.mongodb.DBObject result,
                                  Set<Class<?>> restrictedTypes)
Description copied from interface: MongoTypeMapper
Writes type restrictions to the given DBObject. This usually results in an $in-clause to be generated that restricts the type-key (e.g. _class) to be in the set of type aliases for the given restrictedTypes.

Specified by:
writeTypeRestrictions in interface MongoTypeMapper
Parameters:
result - must not be null
restrictedTypes - must not be null

getFallbackTypeFor

protected TypeInformation<?> getFallbackTypeFor(com.mongodb.DBObject source)
Overrides:
getFallbackTypeFor in class DefaultTypeMapper<com.mongodb.DBObject>

Spring Data MongoDB - Core

Copyright © 2011-2014-2014 Pivotal Software, Inc.. All Rights Reserved.