DATACMNS-1781 - Move off deprecated Spring Framework API.
Use KotlinDetector instead of ReflectionUtils.isKotlinClass(…). Use replacement MethodParameter(…).withContainingClass(…) instead of GenericTypeResolver.resolveParameterType(…). Use MergedAnnotations.from(…).isPresent(…) instead of AnnotationUtils.isAnnotationMetaPresent(…).
This commit is contained in:
@@ -19,7 +19,6 @@ import java.lang.annotation.Annotation;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.data.annotation.Immutable;
|
||||
import org.springframework.data.convert.EntityInstantiator;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -47,7 +46,8 @@ public interface PersistentEntity<T, P extends PersistentProperty<P>> extends It
|
||||
*
|
||||
* @return {@literal null} in case no suitable constructor for automatic construction can be found. This usually
|
||||
* indicates that the instantiation of the object of that persistent entity is done through either a customer
|
||||
* {@link EntityInstantiator} or handled by custom conversion mechanisms entirely.
|
||||
* {@link org.springframework.data.mapping.model.EntityInstantiator} or handled by custom conversion
|
||||
* mechanisms entirely.
|
||||
*/
|
||||
@Nullable
|
||||
PreferredConstructor<T, P> getPersistenceConstructor();
|
||||
|
||||
@@ -55,16 +55,6 @@ public interface PersistentPropertyPathAccessor<T> extends PersistentPropertyAcc
|
||||
@Nullable
|
||||
Object getProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path, GetOptions context);
|
||||
|
||||
/**
|
||||
* Sets the given value for the {@link PersistentProperty} pointed to by the given {@link PersistentPropertyPath}. The
|
||||
* lookup of intermediate values must not yield {@literal null}.
|
||||
*
|
||||
* @param path must not be {@literal null} or empty.
|
||||
* @param value can be {@literal null}.
|
||||
* @see AccessOptions#DEFAULT
|
||||
*/
|
||||
void setProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path, @Nullable Object value);
|
||||
|
||||
/**
|
||||
* Sets the given value for the {@link PersistentProperty} pointed to by the given {@link PersistentPropertyPath}
|
||||
* considering the given {@link AccessOptions}.
|
||||
|
||||
@@ -17,13 +17,13 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.data.annotation.PersistenceConstructor;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.PreferredConstructor;
|
||||
import org.springframework.data.mapping.PreferredConstructor.Parameter;
|
||||
import org.springframework.data.util.ReflectionUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class InstantiationAwarePropertyAccessor<T> implements PersistentProperty
|
||||
PersistentEntity<?, ?> owner = property.getOwner();
|
||||
PersistentPropertyAccessor<T> delegate = delegateFunction.apply(this.bean);
|
||||
|
||||
if (!property.isImmutable() || property.getWither() != null || ReflectionUtils.isKotlinClass(owner.getType())) {
|
||||
if (!property.isImmutable() || property.getWither() != null || KotlinDetector.isKotlinType(owner.getType())) {
|
||||
|
||||
delegate.setProperty(property, value);
|
||||
this.bean = delegate.getBean();
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PreferredConstructor;
|
||||
import org.springframework.data.mapping.PreferredConstructor.Parameter;
|
||||
import org.springframework.data.util.KotlinReflectionUtils;
|
||||
import org.springframework.data.util.ReflectionUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -50,7 +51,7 @@ class KotlinClassGeneratingEntityInstantiator extends ClassGeneratingEntityInsta
|
||||
|
||||
PreferredConstructor<?, ?> constructor = entity.getPersistenceConstructor();
|
||||
|
||||
if (ReflectionUtils.isSupportedKotlinClass(entity.getType()) && constructor != null) {
|
||||
if (KotlinReflectionUtils.isSupportedKotlinClass(entity.getType()) && constructor != null) {
|
||||
|
||||
PreferredConstructor<?, ?> defaultConstructor = new DefaultingKotlinConstructorResolver(entity)
|
||||
.getDefaultConstructor();
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PreferredConstructor;
|
||||
import org.springframework.data.util.ReflectionUtils;
|
||||
import org.springframework.data.util.KotlinReflectionUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MappingInstantiationException extends RuntimeException {
|
||||
|
||||
Constructor<?> constructor = preferredConstructor.getConstructor();
|
||||
|
||||
if (ReflectionUtils.isSupportedKotlinClass(constructor.getDeclaringClass())) {
|
||||
if (KotlinReflectionUtils.isSupportedKotlinClass(constructor.getDeclaringClass())) {
|
||||
|
||||
KFunction<?> kotlinFunction = ReflectJvmMapping.getKotlinFunction(constructor);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PreferredConstructor;
|
||||
import org.springframework.data.mapping.PreferredConstructor.Parameter;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.KotlinReflectionUtils;
|
||||
import org.springframework.data.util.ReflectionUtils;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -182,7 +183,7 @@ public interface PreferredConstructorDiscoverer<T, P extends PersistentProperty<
|
||||
* @return the appropriate discoverer for {@code type}.
|
||||
*/
|
||||
private static Discoverers findDiscoverer(Class<?> type) {
|
||||
return ReflectionUtils.isSupportedKotlinClass(type) ? KOTLIN : DEFAULT;
|
||||
return KotlinReflectionUtils.isSupportedKotlinClass(type) ? KOTLIN : DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user