Skip to content

Move off deprecated API #4165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.x-GH-4164-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data MongoDB</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.x-GH-4164-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.x-GH-4164-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.x-GH-4164-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ interface MapReduceWithProjection<T> extends MapReduceWithQuery<T> {
*
* @author Christoph Strobl
* @since 2.1
* @deprecated since 4.0 in favor of {@link org.springframework.data.mongodb.core.aggregation}.
*/
@Deprecated
interface MapReduceWithOptions<T> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
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;
Expand Down Expand Up @@ -267,7 +267,7 @@ private ArrayJsonSchemaProperty potentiallyEnhanceArraySchemaProperty(MongoPersi
}

private boolean isSpecificType(MongoPersistentProperty property) {
return !ClassTypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
return !TypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
}

private JsonSchemaProperty applyEncryptionDataIfNecessary(MongoPersistentProperty property,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
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;
Expand All @@ -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;
Expand Down Expand Up @@ -139,7 +138,7 @@ public void writeTypeRestrictions(Document result, @Nullable Set<Class<?>> restr

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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,7 @@
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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -353,9 +344,9 @@ String getFieldName(MongoPersistentProperty prop) {
}
};

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;

Expand Down Expand Up @@ -405,7 +396,7 @@ public Map<String, Object> getBean() {
}

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) {
Expand Down Expand Up @@ -498,10 +489,10 @@ private <S> S read(ConversionContext context, MongoPersistentEntity<S> entity, D
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);
Expand Down Expand Up @@ -552,7 +543,7 @@ private Object readAndPopulateIdentifier(ConversionContext context, PersistentPr

MongoPersistentProperty idProperty = entity.getRequiredIdProperty();

if (idProperty.isImmutable() && entity.isConstructorArgument(idProperty)) {
if (idProperty.isImmutable() && entity.isCreatorArgument(idProperty)) {
return rawId;
}

Expand Down Expand Up @@ -587,7 +578,7 @@ private void readProperties(ConversionContext context, MongoPersistentEntity<?>
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);
Expand Down Expand Up @@ -761,7 +752,7 @@ public void write(Object obj, Bson bson) {
}

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;

Expand Down Expand Up @@ -805,12 +796,12 @@ protected void writeInternal(@Nullable Object obj, Bson bson, @Nullable TypeInfo
}

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;
}

Expand Down Expand Up @@ -896,7 +887,7 @@ protected void writePropertyInternal(@Nullable Object obj, DocumentAccessor acce
return;
}

TypeInformation<?> valueType = ClassTypeInformation.from(obj.getClass());
TypeInformation<?> valueType = TypeInformation.of(obj.getClass());
TypeInformation<?> type = prop.getTypeInformation();

if (conversions.hasValueConverter(prop)) {
Expand Down Expand Up @@ -977,7 +968,7 @@ protected void writePropertyInternal(@Nullable Object obj, DocumentAccessor acce
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);
}

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

return writeCollectionInternal(targetCollection, ClassTypeInformation.from(DocumentPointer.class),
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class),
new ArrayList<>());
}

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

TypeInformation<?> componentType = targetType.getComponentType() != null //
? targetType.getComponentType() //
: ClassTypeInformation.OBJECT;
: TypeInformation.OBJECT;
Class<?> rawComponentType = componentType.getType();

Collection<Object> items = targetType.getType().isArray() //
Expand Down Expand Up @@ -1421,7 +1412,7 @@ protected Map<Object, Object> readMap(ConversionContext context, Bson bson, Type
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;
Expand Down Expand Up @@ -1827,7 +1818,7 @@ static Predicate<MongoPersistentProperty> isIdentifier(PersistentEntity<?, ?> en
}

static Predicate<MongoPersistentProperty> isConstructorArgument(PersistentEntity<?, ?> entity) {
return entity::isConstructorArgument;
return entity::isCreatorArgument;
}

/**
Expand Down Expand Up @@ -2046,7 +2037,7 @@ public boolean isCollectionLike() {

@Override
public org.springframework.data.util.TypeInformation<?> getComponentType() {
return ClassTypeInformation.from(persistentProperty.getFieldType());
return TypeInformation.of(persistentProperty.getFieldType());
}

@Override
Expand All @@ -2056,7 +2047,7 @@ public boolean isMap() {

@Override
public org.springframework.data.util.TypeInformation<?> getMapValueType() {
return ClassTypeInformation.from(persistentProperty.getFieldType());
return TypeInformation.of(persistentProperty.getFieldType());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1040,7 +1039,7 @@ public boolean isMap() {
}

public TypeInformation<?> getTypeHint() {
return ClassTypeInformation.OBJECT;
return TypeInformation.OBJECT;
}

}
Expand Down Expand Up @@ -1352,7 +1351,7 @@ public TypeInformation<?> getTypeHint() {

if (property.getActualType().isInterface()
|| java.lang.reflect.Modifier.isAbstract(property.getActualType().getModifiers())) {
return ClassTypeInformation.OBJECT;
return TypeInformation.OBJECT;
}

return NESTED_DOCUMENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
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;

Expand Down Expand Up @@ -134,7 +133,7 @@ protected Object delegateConvertToMongoType(Object source, @Nullable MongoPersis
}

return converter.convertToMongoType(source,
entity == null ? ClassTypeInformation.OBJECT : getTypeHintForEntity(source, entity));
entity == null ? TypeInformation.OBJECT : getTypeHintForEntity(source, entity));
}

@Override
Expand Down Expand Up @@ -209,7 +208,7 @@ private Object getMappedModifier(@Nullable Field field, Modifier modifier) {
: 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static IndexInfo indexInfoOf(Document sourceDocument) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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;

Expand Down Expand Up @@ -76,7 +75,7 @@ static IndexResolver create(
* @see 2.2
*/
default Iterable<? extends IndexDefinition> resolveIndexFor(Class<?> entityType) {
return resolveIndexFor(ClassTypeInformation.from(entityType));
return resolveIndexFor(TypeInformation.of(entityType));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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;

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

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);
Expand Down
Loading