diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapper.java index dadb18ebb..15e97380a 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,9 +45,9 @@ import com.mongodb.DBObject; public class DefaultMongoTypeMapper extends DefaultTypeMapper implements MongoTypeMapper { public static final String DEFAULT_TYPE_KEY = "_class"; - @SuppressWarnings("rawtypes")// + @SuppressWarnings("rawtypes") // private static final TypeInformation LIST_TYPE_INFO = ClassTypeInformation.from(List.class); - @SuppressWarnings("rawtypes")// + @SuppressWarnings("rawtypes") // private static final TypeInformation MAP_TYPE_INFO = ClassTypeInformation.from(Map.class); private final TypeAliasAccessor accessor; @@ -58,12 +58,12 @@ public class DefaultMongoTypeMapper extends DefaultTypeMapper implemen } public DefaultMongoTypeMapper(String typeKey) { - this(typeKey, Arrays.asList(SimpleTypeInformationMapper.INSTANCE)); + this(typeKey, Arrays.asList(new SimpleTypeInformationMapper())); } public DefaultMongoTypeMapper(String typeKey, MappingContext, ?> mappingContext) { - this(typeKey, new DBObjectTypeAliasAccessor(typeKey), mappingContext, Arrays - .asList(SimpleTypeInformationMapper.INSTANCE)); + this(typeKey, new DBObjectTypeAliasAccessor(typeKey), mappingContext, + Arrays.asList(new SimpleTypeInformationMapper())); } public DefaultMongoTypeMapper(String typeKey, List mappers) { @@ -71,7 +71,8 @@ public class DefaultMongoTypeMapper extends DefaultTypeMapper implemen } private DefaultMongoTypeMapper(String typeKey, TypeAliasAccessor accessor, - MappingContext, ?> mappingContext, List mappers) { + MappingContext, ?> mappingContext, + List mappers) { super(accessor, mappingContext, mappers); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java index 83ee16e77..2cb4560cc 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +48,9 @@ public class DefaultMongoTypeMapperUnitTests { @Before public void setUp() { - configurableTypeInformationMapper = new ConfigurableTypeInformationMapper(Collections.singletonMap(String.class, - "1")); - simpleTypeInformationMapper = SimpleTypeInformationMapper.INSTANCE; + configurableTypeInformationMapper = new ConfigurableTypeInformationMapper( + Collections.singletonMap(String.class, "1")); + simpleTypeInformationMapper = new SimpleTypeInformationMapper(); typeMapper = new DefaultMongoTypeMapper(); } @@ -81,8 +81,8 @@ public class DefaultMongoTypeMapperUnitTests { @Test public void writesClassNamesForUnmappedValuesIfConfigured() { - typeMapper = new DefaultMongoTypeMapper(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Arrays.asList( - configurableTypeInformationMapper, simpleTypeInformationMapper)); + typeMapper = new DefaultMongoTypeMapper(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, + Arrays.asList(configurableTypeInformationMapper, simpleTypeInformationMapper)); writesTypeToField(new BasicDBObject(), String.class, "1"); writesTypeToField(new BasicDBObject(), Object.class, Object.class.getName()); @@ -101,11 +101,12 @@ public class DefaultMongoTypeMapperUnitTests { @Test public void readsTypeLoadingClassesForUnmappedTypesIfConfigured() { - typeMapper = new DefaultMongoTypeMapper(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Arrays.asList( - configurableTypeInformationMapper, simpleTypeInformationMapper)); + typeMapper = new DefaultMongoTypeMapper(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, + Arrays.asList(configurableTypeInformationMapper, simpleTypeInformationMapper)); readsTypeFromField(new BasicDBObject(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, "1"), String.class); - readsTypeFromField(new BasicDBObject(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Object.class.getName()), Object.class); + readsTypeFromField(new BasicDBObject(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Object.class.getName()), + Object.class); } /** @@ -144,7 +145,8 @@ public class DefaultMongoTypeMapperUnitTests { @Test public void readsTypeFromDefaultKeyByDefault() { - readsTypeFromField(new BasicDBObject(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, String.class.getName()), String.class); + readsTypeFromField(new BasicDBObject(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, String.class.getName()), + String.class); } @Test