DATACMNS-1508 - Address review comments.
Added ClassUtils.ifPresent(…) to conditionally call back a Consumer<Class> if a class is available from the given ClassLoader. Extract isSuspend(…) method into KotlinReflectionUtils. Deprecate Kotlin-related methods in our ReflectionUtils as parts are available from Spring Framework directly. Rename CoCrudRepository to CoroutineCrudRepository and CoroutineSortingRepository. Add tests for KotlinReflectionUtils to test calls without Kotlin dependencies. Original pull request: #415.
This commit is contained in:
@@ -41,6 +41,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
@@ -57,6 +58,7 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.spel.EvaluationContextProvider;
|
||||
import org.springframework.data.spel.ExtensionAwareEvaluationContextProvider;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.KotlinReflectionUtils;
|
||||
import org.springframework.data.util.Optionals;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
@@ -477,8 +479,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
|
||||
return false;
|
||||
}
|
||||
|
||||
return !org.springframework.data.util.ReflectionUtils.isKotlinClass(type.getType())
|
||||
|| org.springframework.data.util.ReflectionUtils.isSupportedKotlinClass(type.getType());
|
||||
return !KotlinDetector.isKotlinType(type.getType()) || KotlinReflectionUtils.isSupportedKotlinClass(type.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
@@ -76,7 +77,7 @@ class BeanWrapper<T> implements PersistentPropertyAccessor<T> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (org.springframework.data.util.ReflectionUtils.isKotlinClass(property.getOwner().getType())) {
|
||||
if (KotlinDetector.isKotlinType(property.getOwner().getType())) {
|
||||
|
||||
this.bean = (T) KotlinCopyUtil.setProperty(property, bean, value);
|
||||
return;
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.asm.MethodVisitor;
|
||||
import org.springframework.asm.Opcodes;
|
||||
import org.springframework.asm.Type;
|
||||
import org.springframework.cglib.core.ReflectUtils;
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
@@ -1444,7 +1445,7 @@ public class ClassGeneratingPropertyAccessorFactory implements PersistentPropert
|
||||
|
||||
Class<?> type = property.getOwner().getType();
|
||||
|
||||
if (isAccessible(type) && org.springframework.data.util.ReflectionUtils.isKotlinClass(type)) {
|
||||
if (isAccessible(type) && KotlinDetector.isKotlinType(type)) {
|
||||
return KotlinCopyMethod.findCopyMethod(type).filter(it -> it.supportsProperty(property)).isPresent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user