Example usage for org.springframework.data.mongodb.core.convert DefaultMongoTypeMapper DefaultMongoTypeMapper

List of usage examples for org.springframework.data.mongodb.core.convert DefaultMongoTypeMapper DefaultMongoTypeMapper

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.convert DefaultMongoTypeMapper DefaultMongoTypeMapper.

Prototype

public DefaultMongoTypeMapper(@Nullable String typeKey, List<? extends TypeInformationMapper> mappers) 

Source Link

Document

Create a new MongoTypeMapper with fully-qualified type hints using typeKey .

Usage

From source file:org.springframework.data.mongodb.core.convert.MappingMongoConverter.java

/**
 * Creates a new {@link MappingMongoConverter} given the new {@link MongoDbFactory} and {@link MappingContext}.
 * /*from  w w  w. j a  v  a 2  s.com*/
 * @param mongoDbFactory must not be {@literal null}.
 * @param mappingContext must not be {@literal null}.
 */
@SuppressWarnings("deprecation")
public MappingMongoConverter(MongoDbFactory mongoDbFactory,
        MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) {

    super(ConversionServiceFactory.createDefaultConversionService());

    Assert.notNull(mongoDbFactory);
    Assert.notNull(mappingContext);

    this.mongoDbFactory = mongoDbFactory;
    this.mappingContext = mappingContext;
    this.typeMapper = new DefaultMongoTypeMapper(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, mappingContext);
    this.idMapper = new QueryMapper(this);
}

From source file:org.springframework.data.mongodb.core.convert.MappingMongoConverter.java

/**
 * Configures the {@link MongoTypeMapper} to be used to add type information to {@link DBObject}s created by the
 * converter and how to lookup type information from {@link DBObject}s when reading them. Uses a
 * {@link DefaultMongoTypeMapper} by default. Setting this to {@literal null} will reset the {@link TypeMapper} to the
 * default one.//from   w  ww. j a  va 2s .co  m
 * 
 * @param typeMapper the typeMapper to set
 */
public void setTypeMapper(MongoTypeMapper typeMapper) {
    this.typeMapper = typeMapper == null
            ? new DefaultMongoTypeMapper(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, mappingContext)
            : typeMapper;
}