Skip to content

Commit 6e4d463

Browse files
christophstroblmp911de
authored andcommitted
Move off deprecated API.
Closes #4164 Original pull request: #4165.
1 parent a9d2050 commit 6e4d463

File tree

11 files changed

+44
-58
lines changed

11 files changed

+44
-58
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ExecutableMapReduceOperation.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ interface MapReduceWithProjection<T> extends MapReduceWithQuery<T> {
187187
*
188188
* @author Christoph Strobl
189189
* @since 2.1
190+
* @deprecated since 4.0 in favor of {@link org.springframework.data.mongodb.core.aggregation}.
190191
*/
192+
@Deprecated
191193
interface MapReduceWithOptions<T> {
192194

193195
/**

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MappingMongoJsonSchemaCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
4141
import org.springframework.data.mongodb.core.schema.MongoJsonSchema.MongoJsonSchemaBuilder;
4242
import org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject;
43-
import org.springframework.data.util.ClassTypeInformation;
43+
import org.springframework.data.util.TypeInformation;
4444
import org.springframework.util.Assert;
4545
import org.springframework.util.ClassUtils;
4646
import org.springframework.util.CollectionUtils;
@@ -267,7 +267,7 @@ private ArrayJsonSchemaProperty potentiallyEnhanceArraySchemaProperty(MongoPersi
267267
}
268268

269269
private boolean isSpecificType(MongoPersistentProperty property) {
270-
return !ClassTypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
270+
return !TypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
271271
}
272272

273273
private JsonSchemaProperty applyEncryptionDataIfNecessary(MongoPersistentProperty property,

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.springframework.data.mapping.Alias;
3232
import org.springframework.data.mapping.PersistentEntity;
3333
import org.springframework.data.mapping.context.MappingContext;
34-
import org.springframework.data.util.ClassTypeInformation;
3534
import org.springframework.data.util.TypeInformation;
3635
import org.springframework.lang.Nullable;
3736
import org.springframework.util.ObjectUtils;
@@ -52,9 +51,9 @@ public class DefaultMongoTypeMapper extends DefaultTypeMapper<Bson> implements M
5251

5352
public static final String DEFAULT_TYPE_KEY = "_class";
5453
@SuppressWarnings("rawtypes") //
55-
private static final TypeInformation<List> LIST_TYPE_INFO = ClassTypeInformation.from(List.class);
54+
private static final TypeInformation<List> LIST_TYPE_INFO = TypeInformation.of(List.class);
5655
@SuppressWarnings("rawtypes") //
57-
private static final TypeInformation<Map> MAP_TYPE_INFO = ClassTypeInformation.from(Map.class);
56+
private static final TypeInformation<Map> MAP_TYPE_INFO = TypeInformation.MAP;
5857

5958
private final TypeAliasAccessor<Bson> accessor;
6059
private final @Nullable String typeKey;
@@ -139,7 +138,7 @@ public void writeTypeRestrictions(Document result, @Nullable Set<Class<?>> restr
139138

140139
for (Class<?> restrictedType : restrictedTypes) {
141140

142-
Alias typeAlias = getAliasFor(ClassTypeInformation.from(restrictedType));
141+
Alias typeAlias = getAliasFor(TypeInformation.of(restrictedType));
143142

144143
if (!ObjectUtils.nullSafeEquals(Alias.NONE, typeAlias) && typeAlias.isPresent()) {
145144
restrictedMappedTypes.add(typeAlias.getValue());

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,7 @@
5050
import org.springframework.data.annotation.Reference;
5151
import org.springframework.data.convert.CustomConversions;
5252
import org.springframework.data.convert.TypeMapper;
53-
import org.springframework.data.mapping.AccessOptions;
54-
import org.springframework.data.mapping.Association;
55-
import org.springframework.data.mapping.MappingException;
56-
import org.springframework.data.mapping.Parameter;
57-
import org.springframework.data.mapping.PersistentEntity;
58-
import org.springframework.data.mapping.PersistentProperty;
59-
import org.springframework.data.mapping.PersistentPropertyAccessor;
60-
import org.springframework.data.mapping.PersistentPropertyPath;
61-
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
62-
import org.springframework.data.mapping.PreferredConstructor;
53+
import org.springframework.data.mapping.*;
6354
import org.springframework.data.mapping.callback.EntityCallbacks;
6455
import org.springframework.data.mapping.context.MappingContext;
6556
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
@@ -123,7 +114,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
123114
private static final String INCOMPATIBLE_TYPES = "Cannot convert %1$s of type %2$s into an instance of %3$s; Implement a custom Converter<%2$s, %3$s> and register it with the CustomConversions; Parent object was: %4$s";
124115
private static final String INVALID_TYPE_TO_READ = "Expected to read Document %s into type %s but didn't find a PersistentEntity for the latter";
125116

126-
public static final ClassTypeInformation<Bson> BSON = ClassTypeInformation.from(Bson.class);
117+
public static final TypeInformation<Bson> BSON = TypeInformation.of(Bson.class);
127118

128119
protected static final Log LOGGER = LogFactory.getLog(MappingMongoConverter.class);
129120

@@ -353,9 +344,9 @@ String getFieldName(MongoPersistentProperty prop) {
353344
}
354345
};
355346

356-
PreferredConstructor<?, MongoPersistentProperty> persistenceConstructor = mappedEntity.getPersistenceConstructor();
357-
ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null
358-
&& persistenceConstructor.hasParameters()
347+
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = mappedEntity.getInstanceCreatorMetadata();
348+
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
349+
&& instanceCreatorMetadata.hasParameters()
359350
? getParameterProvider(context, mappedEntity, documentAccessor, evaluator)
360351
: NoOpParameterValueProvider.INSTANCE;
361352

@@ -405,7 +396,7 @@ public Map<String, Object> getBean() {
405396
}
406397

407398
public <S extends Object> S read(Class<S> clazz, Bson bson) {
408-
return read(ClassTypeInformation.from(clazz), bson);
399+
return read(TypeInformation.of(clazz), bson);
409400
}
410401

411402
protected <S extends Object> S read(TypeInformation<S> type, Bson bson) {
@@ -498,10 +489,10 @@ private <S> S read(ConversionContext context, MongoPersistentEntity<S> entity, D
498489
SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(bson, spELContext);
499490
DocumentAccessor documentAccessor = new DocumentAccessor(bson);
500491

501-
PreferredConstructor<S, MongoPersistentProperty> persistenceConstructor = entity.getPersistenceConstructor();
492+
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = entity.getInstanceCreatorMetadata();
502493

503-
ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null
504-
&& persistenceConstructor.hasParameters() ? getParameterProvider(context, entity, documentAccessor, evaluator)
494+
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
495+
&& instanceCreatorMetadata.hasParameters() ? getParameterProvider(context, entity, documentAccessor, evaluator)
505496
: NoOpParameterValueProvider.INSTANCE;
506497

507498
EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity);
@@ -552,7 +543,7 @@ private Object readAndPopulateIdentifier(ConversionContext context, PersistentPr
552543

553544
MongoPersistentProperty idProperty = entity.getRequiredIdProperty();
554545

555-
if (idProperty.isImmutable() && entity.isConstructorArgument(idProperty)) {
546+
if (idProperty.isImmutable() && entity.isCreatorArgument(idProperty)) {
556547
return rawId;
557548
}
558549

@@ -587,7 +578,7 @@ private void readProperties(ConversionContext context, MongoPersistentEntity<?>
587578
ConversionContext propertyContext = context.forProperty(prop);
588579
MongoDbPropertyValueProvider valueProviderToUse = valueProvider.withContext(propertyContext);
589580

590-
if (prop.isAssociation() && !entity.isConstructorArgument(prop)) {
581+
if (prop.isAssociation() && !entity.isCreatorArgument(prop)) {
591582

592583
if (callback == null) {
593584
callback = getDbRefResolverCallback(propertyContext, documentAccessor, evaluator);
@@ -761,7 +752,7 @@ public void write(Object obj, Bson bson) {
761752
}
762753

763754
Class<?> entityType = ClassUtils.getUserClass(obj.getClass());
764-
TypeInformation<? extends Object> type = ClassTypeInformation.from(entityType);
755+
TypeInformation<? extends Object> type = TypeInformation.of(entityType);
765756

766757
Object target = obj instanceof LazyLoadingProxy ? ((LazyLoadingProxy) obj).getTarget() : obj;
767758

@@ -805,12 +796,12 @@ protected void writeInternal(@Nullable Object obj, Bson bson, @Nullable TypeInfo
805796
}
806797

807798
if (Map.class.isAssignableFrom(entityType)) {
808-
writeMapInternal((Map<Object, Object>) obj, bson, ClassTypeInformation.MAP);
799+
writeMapInternal((Map<Object, Object>) obj, bson, TypeInformation.MAP);
809800
return;
810801
}
811802

812803
if (Collection.class.isAssignableFrom(entityType)) {
813-
writeCollectionInternal((Collection<?>) obj, ClassTypeInformation.LIST, (Collection<?>) bson);
804+
writeCollectionInternal((Collection<?>) obj, TypeInformation.LIST, (Collection<?>) bson);
814805
return;
815806
}
816807

@@ -896,7 +887,7 @@ protected void writePropertyInternal(@Nullable Object obj, DocumentAccessor acce
896887
return;
897888
}
898889

899-
TypeInformation<?> valueType = ClassTypeInformation.from(obj.getClass());
890+
TypeInformation<?> valueType = TypeInformation.of(obj.getClass());
900891
TypeInformation<?> type = prop.getTypeInformation();
901892

902893
if (conversions.hasValueConverter(prop)) {
@@ -977,7 +968,7 @@ protected void writePropertyInternal(@Nullable Object obj, DocumentAccessor acce
977968
Document document = existingValue instanceof Document ? (Document) existingValue : new Document();
978969

979970
writeInternal(obj, document, entity);
980-
addCustomTypeKeyIfNecessary(ClassTypeInformation.from(prop.getRawType()), obj, document);
971+
addCustomTypeKeyIfNecessary(TypeInformation.of(prop.getRawType()), obj, document);
981972
accessor.put(prop, document);
982973
}
983974

@@ -998,7 +989,7 @@ protected List<Object> createCollection(Collection<?> collection, MongoPersisten
998989
.getPointer();
999990
}).collect(Collectors.toList());
1000991

1001-
return writeCollectionInternal(targetCollection, ClassTypeInformation.from(DocumentPointer.class),
992+
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class),
1002993
new ArrayList<>());
1003994
}
1004995

@@ -1127,7 +1118,7 @@ protected Bson writeMapInternal(Map<Object, Object> obj, Bson bson, TypeInformat
11271118
} else {
11281119
Document document = new Document();
11291120
TypeInformation<?> valueTypeInfo = propertyType.isMap() ? propertyType.getMapValueType()
1130-
: ClassTypeInformation.OBJECT;
1121+
: TypeInformation.OBJECT;
11311122
writeInternal(val, document, valueTypeInfo);
11321123
BsonUtils.addToMap(bson, simpleKey, document);
11331124
}
@@ -1379,7 +1370,7 @@ protected Object readCollectionOrArray(ConversionContext context, Collection<?>
13791370

13801371
TypeInformation<?> componentType = targetType.getComponentType() != null //
13811372
? targetType.getComponentType() //
1382-
: ClassTypeInformation.OBJECT;
1373+
: TypeInformation.OBJECT;
13831374
Class<?> rawComponentType = componentType.getType();
13841375

13851376
Collection<Object> items = targetType.getType().isArray() //
@@ -1421,7 +1412,7 @@ protected Map<Object, Object> readMap(ConversionContext context, Bson bson, Type
14211412
Class<?> mapType = getTypeMapper().readType(bson, targetType).getType();
14221413

14231414
TypeInformation<?> keyType = targetType.getComponentType();
1424-
TypeInformation<?> valueType = targetType.getMapValueType() == null ? ClassTypeInformation.OBJECT
1415+
TypeInformation<?> valueType = targetType.getMapValueType() == null ? TypeInformation.OBJECT
14251416
: targetType.getRequiredMapValueType();
14261417

14271418
Class<?> rawKeyType = keyType != null ? keyType.getType() : Object.class;
@@ -1827,7 +1818,7 @@ static Predicate<MongoPersistentProperty> isIdentifier(PersistentEntity<?, ?> en
18271818
}
18281819

18291820
static Predicate<MongoPersistentProperty> isConstructorArgument(PersistentEntity<?, ?> entity) {
1830-
return entity::isConstructorArgument;
1821+
return entity::isCreatorArgument;
18311822
}
18321823

18331824
/**
@@ -2046,7 +2037,7 @@ public boolean isCollectionLike() {
20462037

20472038
@Override
20482039
public org.springframework.data.util.TypeInformation<?> getComponentType() {
2049-
return ClassTypeInformation.from(persistentProperty.getFieldType());
2040+
return TypeInformation.of(persistentProperty.getFieldType());
20502041
}
20512042

20522043
@Override
@@ -2056,7 +2047,7 @@ public boolean isMap() {
20562047

20572048
@Override
20582049
public org.springframework.data.util.TypeInformation<?> getMapValueType() {
2059-
return ClassTypeInformation.from(persistentProperty.getFieldType());
2050+
return TypeInformation.of(persistentProperty.getFieldType());
20602051
}
20612052

20622053
@Override

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.springframework.data.mongodb.core.query.Query;
4949
import org.springframework.data.mongodb.util.BsonUtils;
5050
import org.springframework.data.mongodb.util.DotPath;
51-
import org.springframework.data.util.ClassTypeInformation;
5251
import org.springframework.data.util.TypeInformation;
5352
import org.springframework.lang.Nullable;
5453
import org.springframework.util.Assert;
@@ -78,7 +77,7 @@ public class QueryMapper {
7877

7978
private static final List<String> DEFAULT_ID_NAMES = Arrays.asList("id", "_id");
8079
private static final Document META_TEXT_SCORE = new Document("$meta", "textScore");
81-
static final ClassTypeInformation<?> NESTED_DOCUMENT = ClassTypeInformation.from(NestedDocument.class);
80+
static final TypeInformation<?> NESTED_DOCUMENT = TypeInformation.of(NestedDocument.class);
8281

8382
private enum MetaMapping {
8483
FORCE, WHEN_PRESENT, IGNORE
@@ -1040,7 +1039,7 @@ public boolean isMap() {
10401039
}
10411040

10421041
public TypeInformation<?> getTypeHint() {
1043-
return ClassTypeInformation.OBJECT;
1042+
return TypeInformation.OBJECT;
10441043
}
10451044

10461045
}
@@ -1352,7 +1351,7 @@ public TypeInformation<?> getTypeHint() {
13521351

13531352
if (property.getActualType().isInterface()
13541353
|| java.lang.reflect.Modifier.isAbstract(property.getActualType().getModifiers())) {
1355-
return ClassTypeInformation.OBJECT;
1354+
return TypeInformation.OBJECT;
13561355
}
13571356

13581357
return NESTED_DOCUMENT;

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/UpdateMapper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.springframework.data.mongodb.core.query.Query;
3232
import org.springframework.data.mongodb.core.query.Update.Modifier;
3333
import org.springframework.data.mongodb.core.query.Update.Modifiers;
34-
import org.springframework.data.util.ClassTypeInformation;
3534
import org.springframework.data.util.TypeInformation;
3635
import org.springframework.lang.Nullable;
3736

@@ -134,7 +133,7 @@ protected Object delegateConvertToMongoType(Object source, @Nullable MongoPersis
134133
}
135134

136135
return converter.convertToMongoType(source,
137-
entity == null ? ClassTypeInformation.OBJECT : getTypeHintForEntity(source, entity));
136+
entity == null ? TypeInformation.OBJECT : getTypeHintForEntity(source, entity));
138137
}
139138

140139
@Override
@@ -209,7 +208,7 @@ private Object getMappedModifier(@Nullable Field field, Modifier modifier) {
209208
: getMappedSort(sortObject, field.getPropertyEntity());
210209
}
211210

212-
TypeInformation<?> typeHint = field == null ? ClassTypeInformation.OBJECT : field.getTypeHint();
211+
TypeInformation<?> typeHint = field == null ? TypeInformation.OBJECT : field.getTypeHint();
213212

214213
return converter.convertToMongoType(value, typeHint);
215214
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static IndexInfo indexInfoOf(Document sourceDocument) {
104104
indexFields.add(IndexField.wildcard(key));
105105
} else {
106106

107-
Double keyValue = new Double(value.toString());
107+
Double keyValue = Double.valueOf(value.toString());
108108

109109
if (ONE.equals(keyValue)) {
110110
indexFields.add(IndexField.create(key, ASC));

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
2020
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
2121
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
22-
import org.springframework.data.util.ClassTypeInformation;
2322
import org.springframework.data.util.TypeInformation;
2423
import org.springframework.util.Assert;
2524

@@ -76,7 +75,7 @@ static IndexResolver create(
7675
* @see 2.2
7776
*/
7877
default Iterable<? extends IndexDefinition> resolveIndexFor(Class<?> entityType) {
79-
return resolveIndexFor(ClassTypeInformation.from(entityType));
78+
return resolveIndexFor(TypeInformation.of(entityType));
8079
}
8180

8281
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoParameters.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.data.mongodb.repository.query.MongoParameters.MongoParameter;
3131
import org.springframework.data.repository.query.Parameter;
3232
import org.springframework.data.repository.query.Parameters;
33-
import org.springframework.data.util.ClassTypeInformation;
3433
import org.springframework.data.util.TypeInformation;
3534
import org.springframework.lang.Nullable;
3635

@@ -64,7 +63,7 @@ public MongoParameters(Method method, boolean isGeoNearMethod) {
6463

6564
this.fullTextIndex = parameterTypes.indexOf(TextCriteria.class);
6665

67-
ClassTypeInformation<?> declaringClassInfo = ClassTypeInformation.from(method.getDeclaringClass());
66+
TypeInformation<?> declaringClassInfo = TypeInformation.of(method.getDeclaringClass());
6867
List<TypeInformation<?>> parameterTypeInfo = declaringClassInfo.getParameterTypes(method);
6968

7069
this.rangeIndex = getTypeIndex(parameterTypeInfo, Range.class, Distance.class);

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryMethod.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.springframework.data.repository.core.RepositoryMetadata;
4242
import org.springframework.data.repository.query.QueryMethod;
4343
import org.springframework.data.repository.util.ReactiveWrappers;
44-
import org.springframework.data.util.ClassTypeInformation;
4544
import org.springframework.data.util.Lazy;
4645
import org.springframework.data.util.TypeInformation;
4746
import org.springframework.lang.Nullable;
@@ -195,7 +194,7 @@ private boolean isGeoNearQuery(Method method) {
195194
}
196195

197196
if (Iterable.class.isAssignableFrom(returnType)) {
198-
TypeInformation<?> from = ClassTypeInformation.fromReturnTypeOf(method);
197+
TypeInformation<?> from = TypeInformation.fromReturnTypeOf(method);
199198
return GeoResult.class.equals(from.getRequiredComponentType().getType());
200199
}
201200

@@ -217,7 +216,7 @@ Optional<Query> lookupQueryAnnotation() {
217216
}
218217

219218
TypeInformation<?> getReturnType() {
220-
return ClassTypeInformation.fromReturnTypeOf(method);
219+
return TypeInformation.fromReturnTypeOf(method);
221220
}
222221

223222
/**

0 commit comments

Comments
 (0)