Move off deprecated API.

Closes #4164
Original pull request: #4165.
This commit is contained in:
Christoph Strobl
2022-09-14 09:35:31 +02:00
committed by Mark Paluch
parent a9d2050806
commit 6e4d463053
11 changed files with 44 additions and 58 deletions

View File

@@ -187,7 +187,9 @@ public interface ExecutableMapReduceOperation {
*
* @author Christoph Strobl
* @since 2.1
* @deprecated since 4.0 in favor of {@link org.springframework.data.mongodb.core.aggregation}.
*/
@Deprecated
interface MapReduceWithOptions<T> {
/**

View File

@@ -40,7 +40,7 @@ import org.springframework.data.mongodb.core.schema.JsonSchemaProperty;
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
import org.springframework.data.mongodb.core.schema.MongoJsonSchema.MongoJsonSchemaBuilder;
import org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
@@ -267,7 +267,7 @@ class MappingMongoJsonSchemaCreator implements MongoJsonSchemaCreator {
}
private boolean isSpecificType(MongoPersistentProperty property) {
return !ClassTypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
return !TypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
}
private JsonSchemaProperty applyEncryptionDataIfNecessary(MongoPersistentProperty property,

View File

@@ -31,7 +31,6 @@ import org.springframework.data.convert.TypeInformationMapper;
import org.springframework.data.mapping.Alias;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
@@ -52,9 +51,9 @@ public class DefaultMongoTypeMapper extends DefaultTypeMapper<Bson> implements M
public static final String DEFAULT_TYPE_KEY = "_class";
@SuppressWarnings("rawtypes") //
private static final TypeInformation<List> LIST_TYPE_INFO = ClassTypeInformation.from(List.class);
private static final TypeInformation<List> LIST_TYPE_INFO = TypeInformation.of(List.class);
@SuppressWarnings("rawtypes") //
private static final TypeInformation<Map> MAP_TYPE_INFO = ClassTypeInformation.from(Map.class);
private static final TypeInformation<Map> MAP_TYPE_INFO = TypeInformation.MAP;
private final TypeAliasAccessor<Bson> accessor;
private final @Nullable String typeKey;
@@ -139,7 +138,7 @@ public class DefaultMongoTypeMapper extends DefaultTypeMapper<Bson> implements M
for (Class<?> restrictedType : restrictedTypes) {
Alias typeAlias = getAliasFor(ClassTypeInformation.from(restrictedType));
Alias typeAlias = getAliasFor(TypeInformation.of(restrictedType));
if (!ObjectUtils.nullSafeEquals(Alias.NONE, typeAlias) && typeAlias.isPresent()) {
restrictedMappedTypes.add(typeAlias.getValue());

View File

@@ -50,16 +50,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.data.annotation.Reference;
import org.springframework.data.convert.CustomConversions;
import org.springframework.data.convert.TypeMapper;
import org.springframework.data.mapping.AccessOptions;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.MappingException;
import org.springframework.data.mapping.Parameter;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
import org.springframework.data.mapping.PreferredConstructor;
import org.springframework.data.mapping.*;
import org.springframework.data.mapping.callback.EntityCallbacks;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
@@ -123,7 +114,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
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";
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";
public static final ClassTypeInformation<Bson> BSON = ClassTypeInformation.from(Bson.class);
public static final TypeInformation<Bson> BSON = TypeInformation.of(Bson.class);
protected static final Log LOGGER = LogFactory.getLog(MappingMongoConverter.class);
@@ -353,9 +344,9 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
};
PreferredConstructor<?, MongoPersistentProperty> persistenceConstructor = mappedEntity.getPersistenceConstructor();
ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null
&& persistenceConstructor.hasParameters()
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = mappedEntity.getInstanceCreatorMetadata();
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
&& instanceCreatorMetadata.hasParameters()
? getParameterProvider(context, mappedEntity, documentAccessor, evaluator)
: NoOpParameterValueProvider.INSTANCE;
@@ -405,7 +396,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
public <S extends Object> S read(Class<S> clazz, Bson bson) {
return read(ClassTypeInformation.from(clazz), bson);
return read(TypeInformation.of(clazz), bson);
}
protected <S extends Object> S read(TypeInformation<S> type, Bson bson) {
@@ -498,10 +489,10 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(bson, spELContext);
DocumentAccessor documentAccessor = new DocumentAccessor(bson);
PreferredConstructor<S, MongoPersistentProperty> persistenceConstructor = entity.getPersistenceConstructor();
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = entity.getInstanceCreatorMetadata();
ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null
&& persistenceConstructor.hasParameters() ? getParameterProvider(context, entity, documentAccessor, evaluator)
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
&& instanceCreatorMetadata.hasParameters() ? getParameterProvider(context, entity, documentAccessor, evaluator)
: NoOpParameterValueProvider.INSTANCE;
EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity);
@@ -552,7 +543,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
MongoPersistentProperty idProperty = entity.getRequiredIdProperty();
if (idProperty.isImmutable() && entity.isConstructorArgument(idProperty)) {
if (idProperty.isImmutable() && entity.isCreatorArgument(idProperty)) {
return rawId;
}
@@ -587,7 +578,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
ConversionContext propertyContext = context.forProperty(prop);
MongoDbPropertyValueProvider valueProviderToUse = valueProvider.withContext(propertyContext);
if (prop.isAssociation() && !entity.isConstructorArgument(prop)) {
if (prop.isAssociation() && !entity.isCreatorArgument(prop)) {
if (callback == null) {
callback = getDbRefResolverCallback(propertyContext, documentAccessor, evaluator);
@@ -761,7 +752,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
Class<?> entityType = ClassUtils.getUserClass(obj.getClass());
TypeInformation<? extends Object> type = ClassTypeInformation.from(entityType);
TypeInformation<? extends Object> type = TypeInformation.of(entityType);
Object target = obj instanceof LazyLoadingProxy ? ((LazyLoadingProxy) obj).getTarget() : obj;
@@ -805,12 +796,12 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
if (Map.class.isAssignableFrom(entityType)) {
writeMapInternal((Map<Object, Object>) obj, bson, ClassTypeInformation.MAP);
writeMapInternal((Map<Object, Object>) obj, bson, TypeInformation.MAP);
return;
}
if (Collection.class.isAssignableFrom(entityType)) {
writeCollectionInternal((Collection<?>) obj, ClassTypeInformation.LIST, (Collection<?>) bson);
writeCollectionInternal((Collection<?>) obj, TypeInformation.LIST, (Collection<?>) bson);
return;
}
@@ -896,7 +887,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
return;
}
TypeInformation<?> valueType = ClassTypeInformation.from(obj.getClass());
TypeInformation<?> valueType = TypeInformation.of(obj.getClass());
TypeInformation<?> type = prop.getTypeInformation();
if (conversions.hasValueConverter(prop)) {
@@ -977,7 +968,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
Document document = existingValue instanceof Document ? (Document) existingValue : new Document();
writeInternal(obj, document, entity);
addCustomTypeKeyIfNecessary(ClassTypeInformation.from(prop.getRawType()), obj, document);
addCustomTypeKeyIfNecessary(TypeInformation.of(prop.getRawType()), obj, document);
accessor.put(prop, document);
}
@@ -998,7 +989,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
.getPointer();
}).collect(Collectors.toList());
return writeCollectionInternal(targetCollection, ClassTypeInformation.from(DocumentPointer.class),
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class),
new ArrayList<>());
}
@@ -1127,7 +1118,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
} else {
Document document = new Document();
TypeInformation<?> valueTypeInfo = propertyType.isMap() ? propertyType.getMapValueType()
: ClassTypeInformation.OBJECT;
: TypeInformation.OBJECT;
writeInternal(val, document, valueTypeInfo);
BsonUtils.addToMap(bson, simpleKey, document);
}
@@ -1379,7 +1370,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
TypeInformation<?> componentType = targetType.getComponentType() != null //
? targetType.getComponentType() //
: ClassTypeInformation.OBJECT;
: TypeInformation.OBJECT;
Class<?> rawComponentType = componentType.getType();
Collection<Object> items = targetType.getType().isArray() //
@@ -1421,7 +1412,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
Class<?> mapType = getTypeMapper().readType(bson, targetType).getType();
TypeInformation<?> keyType = targetType.getComponentType();
TypeInformation<?> valueType = targetType.getMapValueType() == null ? ClassTypeInformation.OBJECT
TypeInformation<?> valueType = targetType.getMapValueType() == null ? TypeInformation.OBJECT
: targetType.getRequiredMapValueType();
Class<?> rawKeyType = keyType != null ? keyType.getType() : Object.class;
@@ -1827,7 +1818,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
static Predicate<MongoPersistentProperty> isConstructorArgument(PersistentEntity<?, ?> entity) {
return entity::isConstructorArgument;
return entity::isCreatorArgument;
}
/**
@@ -2046,7 +2037,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@Override
public org.springframework.data.util.TypeInformation<?> getComponentType() {
return ClassTypeInformation.from(persistentProperty.getFieldType());
return TypeInformation.of(persistentProperty.getFieldType());
}
@Override
@@ -2056,7 +2047,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@Override
public org.springframework.data.util.TypeInformation<?> getMapValueType() {
return ClassTypeInformation.from(persistentProperty.getFieldType());
return TypeInformation.of(persistentProperty.getFieldType());
}
@Override

View File

@@ -48,7 +48,6 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty.Pro
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.util.BsonUtils;
import org.springframework.data.mongodb.util.DotPath;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -78,7 +77,7 @@ public class QueryMapper {
private static final List<String> DEFAULT_ID_NAMES = Arrays.asList("id", "_id");
private static final Document META_TEXT_SCORE = new Document("$meta", "textScore");
static final ClassTypeInformation<?> NESTED_DOCUMENT = ClassTypeInformation.from(NestedDocument.class);
static final TypeInformation<?> NESTED_DOCUMENT = TypeInformation.of(NestedDocument.class);
private enum MetaMapping {
FORCE, WHEN_PRESENT, IGNORE
@@ -1040,7 +1039,7 @@ public class QueryMapper {
}
public TypeInformation<?> getTypeHint() {
return ClassTypeInformation.OBJECT;
return TypeInformation.OBJECT;
}
}
@@ -1352,7 +1351,7 @@ public class QueryMapper {
if (property.getActualType().isInterface()
|| java.lang.reflect.Modifier.isAbstract(property.getActualType().getModifiers())) {
return ClassTypeInformation.OBJECT;
return TypeInformation.OBJECT;
}
return NESTED_DOCUMENT;

View File

@@ -31,7 +31,6 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update.Modifier;
import org.springframework.data.mongodb.core.query.Update.Modifiers;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
@@ -134,7 +133,7 @@ public class UpdateMapper extends QueryMapper {
}
return converter.convertToMongoType(source,
entity == null ? ClassTypeInformation.OBJECT : getTypeHintForEntity(source, entity));
entity == null ? TypeInformation.OBJECT : getTypeHintForEntity(source, entity));
}
@Override
@@ -209,7 +208,7 @@ public class UpdateMapper extends QueryMapper {
: getMappedSort(sortObject, field.getPropertyEntity());
}
TypeInformation<?> typeHint = field == null ? ClassTypeInformation.OBJECT : field.getTypeHint();
TypeInformation<?> typeHint = field == null ? TypeInformation.OBJECT : field.getTypeHint();
return converter.convertToMongoType(value, typeHint);
}

View File

@@ -104,7 +104,7 @@ public class IndexInfo {
indexFields.add(IndexField.wildcard(key));
} else {
Double keyValue = new Double(value.toString());
Double keyValue = Double.valueOf(value.toString());
if (ONE.equals(keyValue)) {
indexFields.add(IndexField.create(key, ASC));

View File

@@ -19,7 +19,6 @@ import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.Assert;
@@ -76,7 +75,7 @@ public interface IndexResolver {
* @see 2.2
*/
default Iterable<? extends IndexDefinition> resolveIndexFor(Class<?> entityType) {
return resolveIndexFor(ClassTypeInformation.from(entityType));
return resolveIndexFor(TypeInformation.of(entityType));
}
}

View File

@@ -30,7 +30,6 @@ import org.springframework.data.mongodb.repository.Near;
import org.springframework.data.mongodb.repository.query.MongoParameters.MongoParameter;
import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.Parameters;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
@@ -64,7 +63,7 @@ public class MongoParameters extends Parameters<MongoParameters, MongoParameter>
this.fullTextIndex = parameterTypes.indexOf(TextCriteria.class);
ClassTypeInformation<?> declaringClassInfo = ClassTypeInformation.from(method.getDeclaringClass());
TypeInformation<?> declaringClassInfo = TypeInformation.of(method.getDeclaringClass());
List<TypeInformation<?>> parameterTypeInfo = declaringClassInfo.getParameterTypes(method);
this.rangeIndex = getTypeIndex(parameterTypeInfo, Range.class, Distance.class);

View File

@@ -41,7 +41,6 @@ import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.query.QueryMethod;
import org.springframework.data.repository.util.ReactiveWrappers;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.Lazy;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
@@ -195,7 +194,7 @@ public class MongoQueryMethod extends QueryMethod {
}
if (Iterable.class.isAssignableFrom(returnType)) {
TypeInformation<?> from = ClassTypeInformation.fromReturnTypeOf(method);
TypeInformation<?> from = TypeInformation.fromReturnTypeOf(method);
return GeoResult.class.equals(from.getRequiredComponentType().getType());
}
@@ -217,7 +216,7 @@ public class MongoQueryMethod extends QueryMethod {
}
TypeInformation<?> getReturnType() {
return ClassTypeInformation.fromReturnTypeOf(method);
return TypeInformation.fromReturnTypeOf(method);
}
/**

View File

@@ -33,7 +33,6 @@ import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.util.ReactiveWrapperConverters;
import org.springframework.data.repository.util.ReactiveWrappers;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.Lazy;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.ClassUtils;
@@ -47,8 +46,8 @@ import org.springframework.util.ClassUtils;
*/
public class ReactiveMongoQueryMethod extends MongoQueryMethod {
private static final ClassTypeInformation<Page> PAGE_TYPE = ClassTypeInformation.from(Page.class);
private static final ClassTypeInformation<Slice> SLICE_TYPE = ClassTypeInformation.from(Slice.class);
private static final TypeInformation<Page> PAGE_TYPE = TypeInformation.of(Page.class);
private static final TypeInformation<Slice> SLICE_TYPE = TypeInformation.of(Slice.class);
private final Method method;
private final Lazy<Boolean> isCollectionQuery;
@@ -89,7 +88,7 @@ public class ReactiveMongoQueryMethod extends MongoQueryMethod {
private boolean isGeoNearQuery(Method method) {
if (ReactiveWrappers.supports(method.getReturnType())) {
TypeInformation<?> from = ClassTypeInformation.fromReturnTypeOf(method);
TypeInformation<?> from = TypeInformation.fromReturnTypeOf(method);
return GeoResult.class.equals(from.getRequiredComponentType().getType());
}
@@ -132,7 +131,7 @@ public class ReactiveMongoQueryMethod extends MongoQueryMethod {
if (hasParameterOfType(method, Pageable.class)) {
TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method);
TypeInformation<?> returnType = TypeInformation.fromReturnTypeOf(method);
boolean multiWrapper = ReactiveWrappers.isMultiValueType(returnType.getType());
boolean singleWrapperWithWrappedPageableResult = ReactiveWrappers.isSingleValueType(returnType.getType())