Polishing.

Move off more deprecated API.

See #4164
Original pull request: #4165.
This commit is contained in:
Mark Paluch
2022-09-16 11:11:06 +02:00
parent 6e4d463053
commit 6937bb519b
6 changed files with 24 additions and 27 deletions

View File

@@ -29,6 +29,7 @@ import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.annotation.Reference;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.BeanWrapperPropertyAccessorFactory;
@@ -239,9 +240,11 @@ class DocumentPointerFactory {
continue;
}
PersistentPropertyPathAccessor<?> propertyPathAccessor = persistentEntity
.getPropertyPathAccessor(propertyAccessor.getBean());
PersistentPropertyPath<?> path = mappingContext
.getPersistentPropertyPath(PropertyPath.from(fieldName, persistentEntity.getTypeInformation()));
Object targetValue = propertyAccessor.getProperty(path);
Object targetValue = propertyPathAccessor.getProperty(path);
target.put(attribute, targetValue);
continue;
}

View File

@@ -39,6 +39,7 @@ import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;
import org.bson.json.JsonReader;
import org.bson.types.ObjectId;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.context.ApplicationContext;
@@ -50,7 +51,16 @@ 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.*;
import org.springframework.data.mapping.AccessOptions;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.InstanceCreatorMetadata;
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.callback.EntityCallbacks;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
@@ -344,7 +354,8 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
};
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = mappedEntity.getInstanceCreatorMetadata();
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = mappedEntity
.getInstanceCreatorMetadata();
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
&& instanceCreatorMetadata.hasParameters()
? getParameterProvider(context, mappedEntity, documentAccessor, evaluator)
@@ -989,8 +1000,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
.getPointer();
}).collect(Collectors.toList());
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class),
new ArrayList<>());
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class), new ArrayList<>());
}
if (property.hasExplicitWriteTarget()) {
@@ -2091,7 +2101,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
@Override
public org.springframework.data.util.TypeInformation<? extends S> specialize(ClassTypeInformation type) {
public org.springframework.data.util.TypeInformation<? extends S> specialize(TypeInformation<?> type) {
return delegate.specialize(type);
}

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.geo;
import java.util.Arrays;
import java.util.List;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.annotation.PersistenceCreator;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
@@ -44,7 +44,7 @@ public class Sphere implements Shape {
* @param center must not be {@literal null}.
* @param radius must not be {@literal null}.
*/
@PersistenceConstructor
@PersistenceCreator
public Sphere(Point center, Distance radius) {
Assert.notNull(center, "Center point must not be null");

View File

@@ -99,6 +99,7 @@ class UnwrappedMongoPersistentEntity<T> implements MongoPersistentEntity<T> {
@Override
@Nullable
@Deprecated
public PreferredConstructor<T, MongoPersistentProperty> getPersistenceConstructor() {
return delegate.getPersistenceConstructor();
}
@@ -110,7 +111,7 @@ class UnwrappedMongoPersistentEntity<T> implements MongoPersistentEntity<T> {
@Override
public boolean isCreatorArgument(PersistentProperty<?> property) {
return delegate.isConstructorArgument(property);
return delegate.isCreatorArgument(property);
}
@Override

View File

@@ -127,7 +127,7 @@ public class ReactiveGridFsTemplate extends GridFsOperationsSupport implements R
}
String filename = upload.getFilename();
Flux<ByteBuffer> source = Flux.from(upload.getContent()).map(DataBuffer::asByteBuffer);
Flux<ByteBuffer> source = Flux.from(upload.getContent()).map(DataBuffer::toByteBuffer);
T fileId = upload.getFileId();
if (fileId == null) {

View File

@@ -369,23 +369,6 @@ public abstract class AbstractReactiveMongoQuery implements RepositoryQuery {
return getCodecRegistry().map(ParameterBindingDocumentCodec::new);
}
/**
* Obtain a {@link Mono publisher} emitting the {@link SpELExpressionEvaluator} suitable to evaluate expressions
* backed by the given dependencies.
*
* @param dependencies must not be {@literal null}.
* @param accessor must not be {@literal null}.
* @return a {@link Mono} emitting the {@link SpELExpressionEvaluator} when ready.
* @since 2.4
* @deprecated in favor of {@link #getSpelEvaluatorFor(ExpressionDependencies, MongoParameterAccessor)}
*/
@Deprecated
protected Mono<SpELExpressionEvaluator> getSpelEvaluatorFor(ExpressionDependencies dependencies,
ConvertingParameterAccessor accessor) {
return getSpelEvaluatorFor(dependencies, (MongoParameterAccessor) accessor);
}
/**
* Obtain a {@link Mono publisher} emitting the {@link SpELExpressionEvaluator} suitable to evaluate expressions
* backed by the given dependencies.