Reintroduce explicit local variable types.
We now reinstate local variable types instead of var as general var usage removes contextual detail that cannot be omitted generally. See #2465
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
@@ -93,20 +94,20 @@ public class AnnotatedTypeScanner implements ResourceLoaderAware, EnvironmentAwa
|
||||
provider.setEnvironment(environment);
|
||||
}
|
||||
|
||||
for (var annotationType : annotationTypess) {
|
||||
for (Class<? extends Annotation> annotationType : annotationTypess) {
|
||||
provider.addIncludeFilter(new AnnotationTypeFilter(annotationType, true, considerInterfaces));
|
||||
}
|
||||
|
||||
Set<Class<?>> types = new HashSet<>();
|
||||
|
||||
var loader = resourceLoader;
|
||||
var classLoader = loader == null ? null : loader.getClassLoader();
|
||||
ResourceLoader loader = resourceLoader;
|
||||
ClassLoader classLoader = loader == null ? null : loader.getClassLoader();
|
||||
|
||||
for (var basePackage : basePackages) {
|
||||
for (String basePackage : basePackages) {
|
||||
|
||||
for (var definition : provider.findCandidateComponents(basePackage)) {
|
||||
for (BeanDefinition definition : provider.findCandidateComponents(basePackage)) {
|
||||
|
||||
var beanClassName = definition.getBeanClassName();
|
||||
String beanClassName = definition.getBeanClassName();
|
||||
|
||||
if (beanClassName == null) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -78,7 +78,7 @@ public class AnnotationDetectionFieldCallback implements FieldCallback {
|
||||
*/
|
||||
public Field getRequiredField() {
|
||||
|
||||
var field = this.field;
|
||||
Field field = this.field;
|
||||
|
||||
if (field == null) {
|
||||
throw new IllegalStateException(String.format("No field found for annotation %s!", annotationType));
|
||||
@@ -95,7 +95,7 @@ public class AnnotationDetectionFieldCallback implements FieldCallback {
|
||||
@Nullable
|
||||
public Class<?> getType() {
|
||||
|
||||
var field = this.field;
|
||||
Field field = this.field;
|
||||
|
||||
return field == null ? null : field.getType();
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class AnnotationDetectionFieldCallback implements FieldCallback {
|
||||
|
||||
Assert.notNull(source, "Source object must not be null!");
|
||||
|
||||
var field = this.field;
|
||||
Field field = this.field;
|
||||
|
||||
if (field == null) {
|
||||
return null;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AnnotationDetectionMethodCallback<A extends Annotation> implements
|
||||
*/
|
||||
public Method getRequiredMethod() {
|
||||
|
||||
var method = this.foundMethod;
|
||||
Method method = this.foundMethod;
|
||||
|
||||
if (method == null) {
|
||||
throw new IllegalStateException(String.format("No method with annotation %s found!", annotationType));
|
||||
@@ -113,7 +113,7 @@ public class AnnotationDetectionMethodCallback<A extends Annotation> implements
|
||||
return;
|
||||
}
|
||||
|
||||
var foundAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, annotationType);
|
||||
A foundAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, annotationType);
|
||||
|
||||
if (foundAnnotation != null) {
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.util;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
|
||||
@@ -61,7 +63,7 @@ public abstract class BeanLookup {
|
||||
@Nullable
|
||||
private static <T> T lookupBean(Class<T> type, ListableBeanFactory beanFactory) {
|
||||
|
||||
var names = beanFactory.getBeansOfType(type, false, false);
|
||||
Map<String, T> names = beanFactory.getBeansOfType(type, false, false);
|
||||
|
||||
switch (names.size()) {
|
||||
|
||||
|
||||
@@ -111,17 +111,17 @@ public class ClassTypeInformation<S> extends TypeDiscoverer<S> {
|
||||
visited.add(type);
|
||||
}
|
||||
|
||||
var source = GenericTypeResolver.getTypeVariableMap(type);
|
||||
Map<TypeVariable, Type> source = GenericTypeResolver.getTypeVariableMap(type);
|
||||
Map<TypeVariable<?>, Type> map = new HashMap<>(source.size());
|
||||
|
||||
for (var entry : source.entrySet()) {
|
||||
for (Map.Entry<TypeVariable, Type> entry : source.entrySet()) {
|
||||
|
||||
var value = entry.getValue();
|
||||
Type value = entry.getValue();
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
|
||||
if (value instanceof Class) {
|
||||
|
||||
for (var nestedEntry : getTypeVariableMap((Class<?>) value, visited).entrySet()) {
|
||||
for (Map.Entry<TypeVariable<?>, Type> nestedEntry : getTypeVariableMap((Class<?>) value, visited).entrySet()) {
|
||||
if (!map.containsKey(nestedEntry.getKey())) {
|
||||
map.put(nestedEntry.getKey(), nestedEntry.getValue());
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.springframework.util.ReflectionUtils.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.NotReadablePropertyException;
|
||||
import org.springframework.beans.NotWritablePropertyException;
|
||||
@@ -46,7 +48,7 @@ public class DirectFieldAccessFallbackBeanWrapper extends BeanWrapperImpl {
|
||||
return super.getPropertyValue(propertyName);
|
||||
} catch (NotReadablePropertyException e) {
|
||||
|
||||
var field = findField(getWrappedClass(), propertyName);
|
||||
Field field = findField(getWrappedClass(), propertyName);
|
||||
|
||||
if (field == null) {
|
||||
throw new NotReadablePropertyException(getWrappedClass(), propertyName,
|
||||
@@ -65,7 +67,7 @@ public class DirectFieldAccessFallbackBeanWrapper extends BeanWrapperImpl {
|
||||
super.setPropertyValue(propertyName, value);
|
||||
} catch (NotWritablePropertyException e) {
|
||||
|
||||
var field = findField(getWrappedClass(), propertyName);
|
||||
Field field = findField(getWrappedClass(), propertyName);
|
||||
|
||||
if (field == null) {
|
||||
throw new NotWritablePropertyException(getWrappedClass(), propertyName,
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.util;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
@@ -52,7 +53,7 @@ class GenericArrayTypeInformation<S> extends ParentTypeAwareTypeInformation<S> {
|
||||
@NonNull
|
||||
protected TypeInformation<?> doGetComponentType() {
|
||||
|
||||
var componentType = type.getGenericComponentType();
|
||||
Type componentType = type.getGenericComponentType();
|
||||
return createInfo(componentType);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@ package org.springframework.data.util;
|
||||
|
||||
import kotlin.jvm.JvmClassMappingKt;
|
||||
import kotlin.reflect.KCallable;
|
||||
import kotlin.reflect.KClass;
|
||||
import kotlin.reflect.KFunction;
|
||||
import kotlin.reflect.KMutableProperty;
|
||||
import kotlin.reflect.KProperty;
|
||||
import kotlin.reflect.KType;
|
||||
import kotlin.reflect.jvm.KTypesJvm;
|
||||
import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||
|
||||
@@ -76,7 +78,7 @@ public final class KotlinReflectionUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
var kotlinClass = JvmClassMappingKt.getKotlinClass(type);
|
||||
KClass<?> kotlinClass = JvmClassMappingKt.getKotlinClass(type);
|
||||
return kotlinClass.isData();
|
||||
}
|
||||
|
||||
@@ -90,7 +92,7 @@ public final class KotlinReflectionUtils {
|
||||
@Nullable
|
||||
public static KFunction<?> findKotlinFunction(Method method) {
|
||||
|
||||
var kotlinFunction = ReflectJvmMapping.getKotlinFunction(method);
|
||||
KFunction<?> kotlinFunction = ReflectJvmMapping.getKotlinFunction(method);
|
||||
|
||||
// Fallback to own lookup because there's no public Kotlin API for that kind of lookup until
|
||||
// https://youtrack.jetbrains.com/issue/KT-20768 gets resolved.
|
||||
@@ -106,7 +108,7 @@ public final class KotlinReflectionUtils {
|
||||
*/
|
||||
public static boolean isSuspend(Method method) {
|
||||
|
||||
var invokedFunction = KotlinDetector.isKotlinType(method.getDeclaringClass()) ? findKotlinFunction(method)
|
||||
KFunction<?> invokedFunction = KotlinDetector.isKotlinType(method.getDeclaringClass()) ? findKotlinFunction(method)
|
||||
: null;
|
||||
|
||||
return invokedFunction != null && invokedFunction.isSuspend();
|
||||
@@ -120,7 +122,7 @@ public final class KotlinReflectionUtils {
|
||||
*/
|
||||
public static Class<?> getReturnType(Method method) {
|
||||
|
||||
var kotlinFunction = KotlinReflectionUtils.findKotlinFunction(method);
|
||||
KFunction<?> kotlinFunction = KotlinReflectionUtils.findKotlinFunction(method);
|
||||
|
||||
if (kotlinFunction == null) {
|
||||
throw new IllegalArgumentException(String.format("Cannot resolve %s to a KFunction!", method));
|
||||
@@ -138,13 +140,13 @@ public final class KotlinReflectionUtils {
|
||||
*/
|
||||
static boolean isNullable(MethodParameter parameter) {
|
||||
|
||||
var method = parameter.getMethod();
|
||||
Method method = parameter.getMethod();
|
||||
|
||||
if (method == null) {
|
||||
throw new IllegalStateException(String.format("Cannot obtain method from parameter %s!", parameter));
|
||||
}
|
||||
|
||||
var kotlinFunction = findKotlinFunction(method);
|
||||
KFunction<?> kotlinFunction = findKotlinFunction(method);
|
||||
|
||||
if (kotlinFunction == null) {
|
||||
throw new IllegalArgumentException(String.format("Cannot resolve %s to a Kotlin function!", parameter));
|
||||
@@ -158,7 +160,7 @@ public final class KotlinReflectionUtils {
|
||||
// see https://github.com/spring-projects/spring-framework/issues/23991
|
||||
if (kotlinFunction.getParameters().size() > parameter.getParameterIndex() + 1) {
|
||||
|
||||
var type = parameter.getParameterIndex() == -1 //
|
||||
KType type = parameter.getParameterIndex() == -1 //
|
||||
? kotlinFunction.getReturnType() //
|
||||
: kotlinFunction.getParameters().get(parameter.getParameterIndex() + 1).getType();
|
||||
|
||||
@@ -170,7 +172,7 @@ public final class KotlinReflectionUtils {
|
||||
|
||||
private static boolean isLast(MethodParameter parameter) {
|
||||
|
||||
var method = parameter.getMethod();
|
||||
Method method = parameter.getMethod();
|
||||
|
||||
return method != null && parameter.getParameterIndex() == method.getParameterCount() - 1;
|
||||
}
|
||||
@@ -183,7 +185,7 @@ public final class KotlinReflectionUtils {
|
||||
*/
|
||||
private static Optional<? extends KFunction<?>> findKFunction(Method method) {
|
||||
|
||||
var kotlinClass = JvmClassMappingKt.getKotlinClass(method.getDeclaringClass());
|
||||
KClass<?> kotlinClass = JvmClassMappingKt.getKotlinClass(method.getDeclaringClass());
|
||||
|
||||
return kotlinClass.getMembers() //
|
||||
.stream() //
|
||||
@@ -213,7 +215,7 @@ public final class KotlinReflectionUtils {
|
||||
|
||||
private static boolean isSame(KFunction<?> function, Method method) {
|
||||
|
||||
var javaMethod = ReflectJvmMapping.getJavaMethod(function);
|
||||
Method javaMethod = ReflectJvmMapping.getJavaMethod(function);
|
||||
return javaMethod != null && javaMethod.equals(method);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class Lazy<T> implements Supplier<T> {
|
||||
*/
|
||||
public T get() {
|
||||
|
||||
var value = getNullable();
|
||||
T value = getNullable();
|
||||
|
||||
if (value == null) {
|
||||
throw new IllegalStateException("Expected lazy evaluation to yield a non-null value but got null!");
|
||||
@@ -164,7 +164,7 @@ public class Lazy<T> implements Supplier<T> {
|
||||
@Nullable
|
||||
public T orElse(@Nullable T value) {
|
||||
|
||||
var nullable = getNullable();
|
||||
T nullable = getNullable();
|
||||
|
||||
return nullable == null ? value : nullable;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class Lazy<T> implements Supplier<T> {
|
||||
|
||||
Assert.notNull(supplier, "Default value supplier must not be null!");
|
||||
|
||||
var value = getNullable();
|
||||
T value = getNullable();
|
||||
|
||||
return value == null ? supplier.get() : value;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class Lazy<T> implements Supplier<T> {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
var result = ObjectUtils.nullSafeHashCode(supplier);
|
||||
int result = ObjectUtils.nullSafeHashCode(supplier);
|
||||
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(value);
|
||||
result = 31 * result + (resolved ? 1 : 0);
|
||||
|
||||
@@ -83,9 +83,9 @@ public class MethodInvocationRecorder {
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> Recorded<T> create(Class<T> type) {
|
||||
|
||||
var interceptor = new RecordingMethodInterceptor();
|
||||
RecordingMethodInterceptor interceptor = new RecordingMethodInterceptor();
|
||||
|
||||
var proxyFactory = new ProxyFactory();
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.addAdvice(interceptor);
|
||||
|
||||
if (!type.isInterface()) {
|
||||
@@ -95,7 +95,7 @@ public class MethodInvocationRecorder {
|
||||
proxyFactory.addInterface(type);
|
||||
}
|
||||
|
||||
var proxy = (T) proxyFactory.getProxy(type.getClassLoader());
|
||||
T proxy = (T) proxyFactory.getProxy(type.getClassLoader());
|
||||
|
||||
return new Recorded<T>(proxy, new MethodInvocationRecorder(Optional.ofNullable(interceptor)));
|
||||
}
|
||||
@@ -112,23 +112,23 @@ public class MethodInvocationRecorder {
|
||||
@SuppressWarnings("null")
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
|
||||
var method = invocation.getMethod();
|
||||
var arguments = invocation.getArguments();
|
||||
Method method = invocation.getMethod();
|
||||
Object[] arguments = invocation.getArguments();
|
||||
|
||||
if (ReflectionUtils.isObjectMethod(method)) {
|
||||
return method.invoke(this, arguments);
|
||||
}
|
||||
|
||||
var type = ResolvableType.forMethodReturnType(method);
|
||||
var rawType = type.resolve(Object.class);
|
||||
ResolvableType type = ResolvableType.forMethodReturnType(method);
|
||||
Class<?> rawType = type.resolve(Object.class);
|
||||
|
||||
if (Collection.class.isAssignableFrom(rawType)) {
|
||||
|
||||
var clazz = type.getGeneric(0).resolve(Object.class);
|
||||
Class<?> clazz = type.getGeneric(0).resolve(Object.class);
|
||||
|
||||
var information = registerInvocation(method, clazz);
|
||||
InvocationInformation information = registerInvocation(method, clazz);
|
||||
|
||||
var collection = CollectionFactory.createCollection(rawType, 1);
|
||||
Collection<Object> collection = CollectionFactory.createCollection(rawType, 1);
|
||||
collection.add(information.getCurrentInstance());
|
||||
|
||||
return collection;
|
||||
@@ -136,10 +136,10 @@ public class MethodInvocationRecorder {
|
||||
|
||||
if (Map.class.isAssignableFrom(rawType)) {
|
||||
|
||||
var clazz = type.getGeneric(1).resolve(Object.class);
|
||||
var information = registerInvocation(method, clazz);
|
||||
Class<?> clazz = type.getGeneric(1).resolve(Object.class);
|
||||
InvocationInformation information = registerInvocation(method, clazz);
|
||||
|
||||
var map = CollectionFactory.createMap(rawType, 1);
|
||||
Map<Object, Object> map = CollectionFactory.createMap(rawType, 1);
|
||||
map.put("_key_", information.getCurrentInstance());
|
||||
|
||||
return map;
|
||||
@@ -154,8 +154,8 @@ public class MethodInvocationRecorder {
|
||||
|
||||
private InvocationInformation registerInvocation(Method method, Class<?> proxyType) {
|
||||
|
||||
var create = Modifier.isFinal(proxyType.getModifiers()) ? new Unrecorded() : create(proxyType);
|
||||
var information = new InvocationInformation(create, method);
|
||||
Recorded<?> create = Modifier.isFinal(proxyType.getModifiers()) ? new Unrecorded() : create(proxyType);
|
||||
InvocationInformation information = new InvocationInformation(create, method);
|
||||
|
||||
return this.information = information;
|
||||
}
|
||||
@@ -183,14 +183,14 @@ public class MethodInvocationRecorder {
|
||||
|
||||
Optional<String> getPropertyPath(List<PropertyNameDetectionStrategy> strategies) {
|
||||
|
||||
var invokedMethod = this.invokedMethod;
|
||||
Method invokedMethod = this.invokedMethod;
|
||||
|
||||
if (invokedMethod == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var propertyName = getPropertyName(invokedMethod, strategies);
|
||||
var next = recorded.getPropertyPath(strategies);
|
||||
String propertyName = getPropertyName(invokedMethod, strategies);
|
||||
Optional<String> next = recorded.getPropertyPath(strategies);
|
||||
|
||||
return Optionals.firstNonEmpty(() -> next.map(it -> propertyName.concat(".").concat(it)), //
|
||||
() -> Optional.of(propertyName));
|
||||
@@ -235,7 +235,7 @@ public class MethodInvocationRecorder {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
var result = ObjectUtils.nullSafeHashCode(recorded);
|
||||
int result = ObjectUtils.nullSafeHashCode(recorded);
|
||||
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(invokedMethod);
|
||||
|
||||
@@ -267,8 +267,8 @@ public class MethodInvocationRecorder {
|
||||
|
||||
private static String getPropertyName(Class<?> type, String methodName) {
|
||||
|
||||
var pattern = getPatternFor(type);
|
||||
var replaced = methodName.replaceFirst(pattern, "");
|
||||
String pattern = getPatternFor(type);
|
||||
String replaced = methodName.replaceFirst(pattern, "");
|
||||
|
||||
return StringUtils.uncapitalize(replaced);
|
||||
}
|
||||
@@ -295,14 +295,14 @@ public class MethodInvocationRecorder {
|
||||
|
||||
public Optional<String> getPropertyPath(PropertyNameDetectionStrategy strategy) {
|
||||
|
||||
var recorder = this.recorder;
|
||||
MethodInvocationRecorder recorder = this.recorder;
|
||||
|
||||
return recorder == null ? Optional.empty() : recorder.getPropertyPath(Arrays.asList(strategy));
|
||||
}
|
||||
|
||||
public Optional<String> getPropertyPath(List<PropertyNameDetectionStrategy> strategies) {
|
||||
|
||||
var recorder = this.recorder;
|
||||
MethodInvocationRecorder recorder = this.recorder;
|
||||
|
||||
return recorder == null ? Optional.empty() : recorder.getPropertyPath(strategies);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class MultiValueMapCollector<T, K, V> implements Collector<T, MultiValueMap<K, V
|
||||
|
||||
return (map1, map2) -> {
|
||||
|
||||
for (var key : map2.keySet()) {
|
||||
for (K key : map2.keySet()) {
|
||||
map1.addAll(key, map2.get(key));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
@@ -34,6 +36,7 @@ import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
* Utility methods to introspect nullability rules declared in packages, classes and methods.
|
||||
@@ -129,9 +132,9 @@ public abstract class NullableUtils {
|
||||
*/
|
||||
public static boolean isNonNull(AnnotatedElement element, ElementType elementType) {
|
||||
|
||||
for (var annotation : element.getAnnotations()) {
|
||||
for (Annotation annotation : element.getAnnotations()) {
|
||||
|
||||
var isNonNull = NON_NULL_ANNOTATION_CLASS.isPresent() ? isNonNull(annotation, elementType)
|
||||
boolean isNonNull = NON_NULL_ANNOTATION_CLASS.isPresent() ? isNonNull(annotation, elementType)
|
||||
: NON_NULLABLE_ANNOTATIONS.contains(annotation.annotationType());
|
||||
|
||||
if (isNonNull) {
|
||||
@@ -148,7 +151,7 @@ public abstract class NullableUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
var annotationClass = NON_NULL_ANNOTATION_CLASS.get();
|
||||
Class<Annotation> annotationClass = NON_NULL_ANNOTATION_CLASS.get();
|
||||
|
||||
if (annotation.annotationType().equals(annotationClass)) {
|
||||
return true;
|
||||
@@ -183,9 +186,9 @@ public abstract class NullableUtils {
|
||||
|
||||
private static boolean isExplicitNullable(Annotation[] annotations) {
|
||||
|
||||
for (var annotation : annotations) {
|
||||
for (Annotation annotation : annotations) {
|
||||
|
||||
var isNullable = NON_NULL_ANNOTATION_CLASS.isPresent() ? isNullable(annotation)
|
||||
boolean isNullable = NON_NULL_ANNOTATION_CLASS.isPresent() ? isNullable(annotation)
|
||||
: NULLABLE_ANNOTATIONS.contains(annotation.annotationType());
|
||||
|
||||
if (isNullable) {
|
||||
@@ -224,21 +227,21 @@ public abstract class NullableUtils {
|
||||
|
||||
if (annotation.annotationType().getName().equals(metaAnnotationName)) {
|
||||
|
||||
var attributes = AnnotationUtils.getAnnotationAttributes(annotation);
|
||||
Map<String, Object> attributes = AnnotationUtils.getAnnotationAttributes(annotation);
|
||||
|
||||
return !attributes.isEmpty() && filter.test((T) attributes.get(attribute));
|
||||
}
|
||||
|
||||
var attributes = AnnotatedElementUtils
|
||||
MultiValueMap<String, Object> attributes = AnnotatedElementUtils
|
||||
.getAllAnnotationAttributes(annotation.annotationType(), metaAnnotationName);
|
||||
|
||||
if (attributes == null || attributes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var elementTypes = attributes.get(attribute);
|
||||
List<Object> elementTypes = attributes.get(attribute);
|
||||
|
||||
for (var value : elementTypes) {
|
||||
for (Object value : elementTypes) {
|
||||
|
||||
if (filter.test((T) value)) {
|
||||
return true;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class NullableWrapper {
|
||||
*/
|
||||
public Class<?> getValueType() {
|
||||
|
||||
var value = this.value;
|
||||
Object value = this.value;
|
||||
|
||||
return value == null ? Object.class : value.getClass();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class NullableWrapperConverters {
|
||||
|
||||
return supportsCache.computeIfAbsent(type, key -> {
|
||||
|
||||
for (var candidate : WRAPPER_TYPES) {
|
||||
for (WrapperType candidate : WRAPPER_TYPES) {
|
||||
if (candidate.getType().isAssignableFrom(key)) {
|
||||
return true;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public abstract class NullableWrapperConverters {
|
||||
|
||||
Assert.notNull(type, "Type must not be null!");
|
||||
|
||||
for (var candidate : UNWRAPPER_TYPES) {
|
||||
for (WrapperType candidate : UNWRAPPER_TYPES) {
|
||||
if (candidate.getType().isAssignableFrom(type)) {
|
||||
return true;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public abstract class NullableWrapperConverters {
|
||||
|
||||
public static boolean isSingleValue(Class<?> type) {
|
||||
|
||||
for (var candidate : WRAPPER_TYPES) {
|
||||
for (WrapperType candidate : WRAPPER_TYPES) {
|
||||
if (candidate.getType().isAssignableFrom(type)) {
|
||||
return candidate.isSingleValue();
|
||||
}
|
||||
@@ -184,9 +184,9 @@ public abstract class NullableWrapperConverters {
|
||||
return source;
|
||||
}
|
||||
|
||||
for (var converter : UNWRAPPERS) {
|
||||
for (Converter<Object, Object> converter : UNWRAPPERS) {
|
||||
|
||||
var result = converter.convert(source);
|
||||
Object result = converter.convert(source);
|
||||
|
||||
if (result != source) {
|
||||
return result;
|
||||
@@ -206,9 +206,9 @@ public abstract class NullableWrapperConverters {
|
||||
|
||||
Assert.notNull(type, "type must not be null");
|
||||
|
||||
var rawType = type.getType();
|
||||
Class<?> rawType = type.getType();
|
||||
|
||||
var needToUnwrap = supports(rawType) //
|
||||
boolean needToUnwrap = supports(rawType) //
|
||||
|| Stream.class.isAssignableFrom(rawType);
|
||||
|
||||
return needToUnwrap ? unwrapActualType(type.getRequiredComponentType()) : type;
|
||||
@@ -259,8 +259,8 @@ public abstract class NullableWrapperConverters {
|
||||
return null;
|
||||
}
|
||||
|
||||
var wrapper = (NullableWrapper) source;
|
||||
var value = wrapper.getValue();
|
||||
NullableWrapper wrapper = (NullableWrapper) source;
|
||||
Object value = wrapper.getValue();
|
||||
|
||||
return value == null ? nullValue : wrap(value);
|
||||
}
|
||||
@@ -484,7 +484,7 @@ public abstract class NullableWrapperConverters {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
var result = ObjectUtils.nullSafeHashCode(type);
|
||||
int result = ObjectUtils.nullSafeHashCode(type);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(cardinality);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public final class Pair<S, T> {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
var result = ObjectUtils.nullSafeHashCode(first);
|
||||
int result = ObjectUtils.nullSafeHashCode(first);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(second);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -171,9 +171,9 @@ public class ParameterTypes {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parameterTypes = method.getParameterTypes();
|
||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
|
||||
for (var i = 0; i < parameterTypes.length; i++) {
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
if (parameterTypes[i] != types.get(i).getType()) {
|
||||
return false;
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class ParameterTypes {
|
||||
|
||||
protected Optional<ParameterTypes> withLastVarArgs() {
|
||||
|
||||
var lastDescriptor = types.get(types.size() - 1);
|
||||
TypeDescriptor lastDescriptor = types.get(types.size() - 1);
|
||||
|
||||
return lastDescriptor.isArray() //
|
||||
? Optional.empty() //
|
||||
@@ -214,7 +214,7 @@ public class ParameterTypes {
|
||||
@SuppressWarnings("null")
|
||||
private ParameterTypes withVarArgs(TypeDescriptor descriptor) {
|
||||
|
||||
var lastDescriptor = types.get(types.size() - 1);
|
||||
TypeDescriptor lastDescriptor = types.get(types.size() - 1);
|
||||
|
||||
if (lastDescriptor.isArray() && lastDescriptor.getElementTypeDescriptor().equals(descriptor)) {
|
||||
return this;
|
||||
@@ -236,7 +236,7 @@ public class ParameterTypes {
|
||||
|
||||
withLastVarArgs().ifPresent(alternatives::add);
|
||||
|
||||
var objectVarArgs = withVarArgs(OBJECT_DESCRIPTOR);
|
||||
ParameterTypes objectVarArgs = withVarArgs(OBJECT_DESCRIPTOR);
|
||||
|
||||
if (!alternatives.contains(objectVarArgs)) {
|
||||
alternatives.add(objectVarArgs);
|
||||
@@ -259,9 +259,9 @@ public class ParameterTypes {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parameterTypes = method.getParameterTypes();
|
||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
|
||||
for (var i = 0; i < parameterTypes.length; i++) {
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
if (!TypeUtils.isAssignable(parameterTypes[i], types.get(i).getType())) {
|
||||
return false;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ public class ParameterTypes {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
var result = super.hashCode();
|
||||
int result = super.hashCode();
|
||||
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(tail);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
|
||||
if (isMap()) {
|
||||
|
||||
var arguments = type.getActualTypeArguments();
|
||||
Type[] arguments = type.getActualTypeArguments();
|
||||
|
||||
if (arguments.length > 1) {
|
||||
return createInfo(arguments[1]);
|
||||
@@ -79,13 +79,13 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
Optional.ofNullable(rawType.getGenericSuperclass()).ifPresent(supertypes::add);
|
||||
supertypes.addAll(Arrays.asList(rawType.getGenericInterfaces()));
|
||||
|
||||
var result = supertypes.stream()//
|
||||
Optional<TypeInformation<?>> result = supertypes.stream()//
|
||||
.map(it -> Pair.of(it, resolveType(it)))//
|
||||
.filter(it -> Map.class.isAssignableFrom(it.getSecond()))//
|
||||
.<TypeInformation<?>> map(it -> {
|
||||
|
||||
var parameterizedSupertype = (ParameterizedType) it.getFirst();
|
||||
var arguments = parameterizedSupertype.getActualTypeArguments();
|
||||
ParameterizedType parameterizedSupertype = (ParameterizedType) it.getFirst();
|
||||
Type[] arguments = parameterizedSupertype.getActualTypeArguments();
|
||||
return createInfo(arguments[1]);
|
||||
}).findFirst();
|
||||
|
||||
@@ -97,7 +97,7 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
|
||||
List<TypeInformation<?>> result = new ArrayList<>();
|
||||
|
||||
for (var argument : type.getActualTypeArguments()) {
|
||||
for (Type argument : type.getActualTypeArguments()) {
|
||||
result.add(createInfo(argument));
|
||||
}
|
||||
|
||||
@@ -111,17 +111,17 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
return true;
|
||||
}
|
||||
|
||||
var rawType = getType();
|
||||
var rawTargetType = target.getType();
|
||||
Class<T> rawType = getType();
|
||||
Class<?> rawTargetType = target.getType();
|
||||
|
||||
if (!rawType.isAssignableFrom(rawTargetType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var otherTypeInformation = rawType.equals(rawTargetType) ? target
|
||||
TypeInformation<?> otherTypeInformation = rawType.equals(rawTargetType) ? target
|
||||
: target.getSuperTypeInformation(rawType);
|
||||
|
||||
var myParameters = getTypeArguments();
|
||||
List<TypeInformation<?>> myParameters = getTypeArguments();
|
||||
List<TypeInformation<?>> typeParameters = otherTypeInformation == null ? Collections.emptyList()
|
||||
: otherTypeInformation.getTypeArguments();
|
||||
|
||||
@@ -129,7 +129,7 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < myParameters.size(); i++) {
|
||||
for (int i = 0; i < myParameters.size(); i++) {
|
||||
if (!myParameters.get(i).isAssignableFrom(typeParameters.get(i))) {
|
||||
return false;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
return (TypeInformation<? extends T>) type;
|
||||
}
|
||||
|
||||
var asSupertype = type.getSuperTypeInformation(getType());
|
||||
TypeInformation<?> asSupertype = type.getSuperTypeInformation(getType());
|
||||
|
||||
if (asSupertype == null || !ParameterizedTypeInformation.class.isInstance(asSupertype)) {
|
||||
return super.specialize(type);
|
||||
@@ -202,15 +202,15 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
|
||||
private boolean isResolvedCompletely() {
|
||||
|
||||
var typeArguments = type.getActualTypeArguments();
|
||||
Type[] typeArguments = type.getActualTypeArguments();
|
||||
|
||||
if (typeArguments.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var typeArgument : typeArguments) {
|
||||
for (Type typeArgument : typeArguments) {
|
||||
|
||||
var info = createInfo(typeArgument);
|
||||
TypeInformation<?> info = createInfo(typeArgument);
|
||||
|
||||
if (info instanceof ParameterizedTypeInformation) {
|
||||
if (!((ParameterizedTypeInformation<?>) info).isResolvedCompletely()) {
|
||||
@@ -236,9 +236,9 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
*/
|
||||
private static Map<TypeVariable<?>, Type> calculateTypeVariables(ParameterizedType type, TypeDiscoverer<?> parent) {
|
||||
|
||||
var resolvedType = parent.resolveType(type);
|
||||
Class<?> resolvedType = parent.resolveType(type);
|
||||
TypeVariable<?>[] typeParameters = resolvedType.getTypeParameters();
|
||||
var arguments = type.getActualTypeArguments();
|
||||
Type[] arguments = type.getActualTypeArguments();
|
||||
|
||||
Map<TypeVariable<?>, Type> localTypeVariables = new HashMap<>(parent.getTypeVariableMap());
|
||||
|
||||
@@ -263,7 +263,7 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
return source;
|
||||
}
|
||||
|
||||
var value = variables.get(source);
|
||||
Type value = variables.get(source);
|
||||
|
||||
return value == null ? source : flattenTypeVariable(value, variables);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class ParentTypeAwareTypeInformation<S> extends TypeDiscoverer<S
|
||||
return false;
|
||||
}
|
||||
|
||||
var that = (ParentTypeAwareTypeInformation<?>) obj;
|
||||
ParentTypeAwareTypeInformation<?> that = (ParentTypeAwareTypeInformation<?>) obj;
|
||||
return this.parent == null ? that.parent == null : this.parent.equals(that.parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,10 +80,10 @@ public abstract class ParsingUtils {
|
||||
|
||||
Assert.notNull(source, "Source string must not be null!");
|
||||
|
||||
var parts = CAMEL_CASE.split(source);
|
||||
String[] parts = CAMEL_CASE.split(source);
|
||||
List<String> result = new ArrayList<>(parts.length);
|
||||
|
||||
for (var part : parts) {
|
||||
for (String part : parts) {
|
||||
result.add(toLower ? part.toLowerCase() : part);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,9 +55,9 @@ public abstract class ProxyUtils {
|
||||
|
||||
return USER_TYPES.computeIfAbsent(type, it -> {
|
||||
|
||||
var result = it;
|
||||
Class<?> result = it;
|
||||
|
||||
for (var proxyDetector : DETECTORS) {
|
||||
for (ProxyDetector proxyDetector : DETECTORS) {
|
||||
result = proxyDetector.getUserType(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class ReflectionUtils {
|
||||
public static <T> T createInstanceIfPresent(String classname, T defaultInstance) {
|
||||
|
||||
try {
|
||||
var type = ClassUtils.forName(classname, ClassUtils.getDefaultClassLoader());
|
||||
Class<?> type = ClassUtils.forName(classname, ClassUtils.getDefaultClassLoader());
|
||||
return (T) BeanUtils.instantiateClass(type);
|
||||
} catch (Exception e) {
|
||||
return defaultInstance;
|
||||
@@ -182,12 +182,12 @@ public final class ReflectionUtils {
|
||||
Assert.notNull(type, "Type must not be null!");
|
||||
Assert.notNull(filter, "Filter must not be null!");
|
||||
|
||||
var targetClass = type;
|
||||
Class<?> targetClass = type;
|
||||
Field foundField = null;
|
||||
|
||||
while (targetClass != Object.class) {
|
||||
|
||||
for (var field : targetClass.getDeclaredFields()) {
|
||||
for (Field field : targetClass.getDeclaredFields()) {
|
||||
|
||||
if (!filter.matches(field)) {
|
||||
continue;
|
||||
@@ -220,7 +220,7 @@ public final class ReflectionUtils {
|
||||
*/
|
||||
public static Field findRequiredField(Class<?> type, String name) {
|
||||
|
||||
var result = org.springframework.util.ReflectionUtils.findField(type, name);
|
||||
Field result = org.springframework.util.ReflectionUtils.findField(type, name);
|
||||
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException(String.format("Unable to find field %s on %s!", name, type));
|
||||
@@ -275,11 +275,11 @@ public final class ReflectionUtils {
|
||||
Assert.notNull(name, "Method name must not be null");
|
||||
|
||||
Method result = null;
|
||||
var searchType = type;
|
||||
Class<?> searchType = type;
|
||||
while (searchType != null) {
|
||||
var methods = (searchType.isInterface() ? searchType.getMethods()
|
||||
Method[] methods = (searchType.isInterface() ? searchType.getMethods()
|
||||
: org.springframework.util.ReflectionUtils.getDeclaredMethods(searchType));
|
||||
for (var method : methods) {
|
||||
for (Method method : methods) {
|
||||
if (name.equals(method.getName()) && hasSameParams(method, parameterTypes)) {
|
||||
if (result == null || result.isSynthetic() || result.isBridge()) {
|
||||
result = method;
|
||||
@@ -291,7 +291,7 @@ public final class ReflectionUtils {
|
||||
|
||||
if (result == null) {
|
||||
|
||||
var parameterTypeNames = Arrays.stream(parameterTypes) //
|
||||
String parameterTypeNames = Arrays.stream(parameterTypes) //
|
||||
.map(Object::toString) //
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
@@ -318,7 +318,7 @@ public final class ReflectionUtils {
|
||||
Assert.notNull(method, "Method must not be null!");
|
||||
|
||||
Stream<Class<?>> returnType = Stream.of(method.getReturnType());
|
||||
var parameterTypes = Arrays.stream(method.getParameterTypes());
|
||||
Stream<Class<?>> parameterTypes = Arrays.stream(method.getParameterTypes());
|
||||
|
||||
return Stream.concat(returnType, parameterTypes);
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public final class ReflectionUtils {
|
||||
.map(ResolvableType::getRawClass)//
|
||||
.collect(Collectors.toList());
|
||||
|
||||
var method = org.springframework.util.ReflectionUtils.findMethod(type, name,
|
||||
Method method = org.springframework.util.ReflectionUtils.findMethod(type, name,
|
||||
collect.toArray(new Class<?>[collect.size()]));
|
||||
|
||||
return Optional.ofNullable(method)//
|
||||
@@ -356,11 +356,11 @@ public final class ReflectionUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
var index = 0;
|
||||
int index = 0;
|
||||
|
||||
for (var argumentType : parameterTypes) {
|
||||
for (Class<?> argumentType : parameterTypes) {
|
||||
|
||||
var argument = arguments[index];
|
||||
Object argument = arguments[index];
|
||||
|
||||
// Reject nulls for primitives
|
||||
if (argumentType.isPrimitive() && argument == null) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public interface StreamUtils {
|
||||
*/
|
||||
static <T> Stream<T> createStreamFromIterator(Iterator<T> iterator) {
|
||||
|
||||
var spliterator = Spliterators.spliteratorUnknownSize(iterator, Spliterator.NONNULL);
|
||||
Spliterator<T> spliterator = Spliterators.spliteratorUnknownSize(iterator, Spliterator.NONNULL);
|
||||
return StreamSupport.stream(spliterator, false);
|
||||
}
|
||||
|
||||
@@ -128,12 +128,12 @@ public interface StreamUtils {
|
||||
Assert.notNull(right, "Right must not be null!");
|
||||
Assert.notNull(combiner, "Combiner must not be null!");
|
||||
|
||||
var lefts = left.spliterator();
|
||||
var rights = right.spliterator();
|
||||
Spliterator<L> lefts = left.spliterator();
|
||||
Spliterator<R> rights = right.spliterator();
|
||||
|
||||
var size = Long.min(lefts.estimateSize(), rights.estimateSize());
|
||||
var characteristics = lefts.characteristics() & rights.characteristics();
|
||||
var parallel = left.isParallel() || right.isParallel();
|
||||
long size = Long.min(lefts.estimateSize(), rights.estimateSize());
|
||||
int characteristics = lefts.characteristics() & rights.characteristics();
|
||||
boolean parallel = left.isParallel() || right.isParallel();
|
||||
|
||||
return StreamSupport.stream(new AbstractSpliterator<T>(size, characteristics) {
|
||||
|
||||
@@ -141,16 +141,16 @@ public interface StreamUtils {
|
||||
@SuppressWarnings("null")
|
||||
public boolean tryAdvance(Consumer<? super T> action) {
|
||||
|
||||
var leftSink = new Sink<L>();
|
||||
var rightSink = new Sink<R>();
|
||||
Sink<L> leftSink = new Sink<L>();
|
||||
Sink<R> rightSink = new Sink<R>();
|
||||
|
||||
var leftAdvance = lefts.tryAdvance(leftSink);
|
||||
boolean leftAdvance = lefts.tryAdvance(leftSink);
|
||||
|
||||
if (!leftAdvance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var rightAdvance = rights.tryAdvance(rightSink);
|
||||
boolean rightAdvance = rights.tryAdvance(rightSink);
|
||||
|
||||
if (!rightAdvance) {
|
||||
return false;
|
||||
|
||||
@@ -17,13 +17,24 @@ package org.springframework.data.util;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.lang.reflect.WildcardType;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -50,7 +61,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
static {
|
||||
|
||||
var classLoader = TypeDiscoverer.class.getClassLoader();
|
||||
ClassLoader classLoader = TypeDiscoverer.class.getClassLoader();
|
||||
|
||||
Set<Class<?>> mapTypes = new HashSet<>();
|
||||
mapTypes.add(Map.class);
|
||||
@@ -147,7 +158,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
if (fieldType instanceof WildcardType wildcardType) {
|
||||
|
||||
var bounds = wildcardType.getLowerBounds();
|
||||
Type[] bounds = wildcardType.getLowerBounds();
|
||||
|
||||
if (bounds.length > 0) {
|
||||
return createInfo(bounds[0]);
|
||||
@@ -183,7 +194,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
Assert.notNull(constructor, "Constructor must not be null!");
|
||||
|
||||
List<TypeInformation<?>> parameterTypes = new ArrayList<>(constructor.getParameterCount());
|
||||
for (var parameter : constructor.getParameters()) {
|
||||
for (Parameter parameter : constructor.getParameters()) {
|
||||
parameterTypes.add(createInfo(parameter.getParameterizedType()));
|
||||
}
|
||||
return parameterTypes;
|
||||
@@ -192,14 +203,14 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
@Nullable
|
||||
public TypeInformation<?> getProperty(String fieldname) {
|
||||
|
||||
var separatorIndex = fieldname.indexOf('.');
|
||||
int separatorIndex = fieldname.indexOf('.');
|
||||
|
||||
if (separatorIndex == -1) {
|
||||
return fieldTypes.computeIfAbsent(fieldname, this::getPropertyInformation).orElse(null);
|
||||
}
|
||||
|
||||
var head = fieldname.substring(0, separatorIndex);
|
||||
var info = getProperty(head);
|
||||
String head = fieldname.substring(0, separatorIndex);
|
||||
TypeInformation<?> info = getProperty(head);
|
||||
|
||||
if (info == null) {
|
||||
return null;
|
||||
@@ -220,7 +231,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
private Optional<TypeInformation<?>> getPropertyInformation(String fieldname) {
|
||||
|
||||
Class<?> rawType = getType();
|
||||
var field = ReflectionUtils.findField(rawType, fieldname);
|
||||
Field field = ReflectionUtils.findField(rawType, fieldname);
|
||||
|
||||
if (field != null) {
|
||||
return Optional.of(createInfo(field.getGenericType()));
|
||||
@@ -238,7 +249,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
*/
|
||||
private static Optional<PropertyDescriptor> findPropertyDescriptor(Class<?> type, String fieldname) {
|
||||
|
||||
var descriptor = BeanUtils.getPropertyDescriptor(type, fieldname);
|
||||
PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(type, fieldname);
|
||||
|
||||
if (descriptor != null) {
|
||||
return Optional.of(descriptor);
|
||||
@@ -263,7 +274,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
@Nullable
|
||||
private static Type getGenericType(PropertyDescriptor descriptor) {
|
||||
|
||||
var method = descriptor.getReadMethod();
|
||||
Method method = descriptor.getReadMethod();
|
||||
|
||||
if (method != null) {
|
||||
return method.getGenericReturnType();
|
||||
@@ -275,7 +286,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
return null;
|
||||
}
|
||||
|
||||
var parameterTypes = method.getGenericParameterTypes();
|
||||
Type[] parameterTypes = method.getGenericParameterTypes();
|
||||
return parameterTypes.length == 0 ? null : parameterTypes[0];
|
||||
}
|
||||
|
||||
@@ -310,9 +321,9 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
public boolean isMap() {
|
||||
|
||||
var type = getType();
|
||||
Class<S> type = getType();
|
||||
|
||||
for (var mapType : MAP_TYPES) {
|
||||
for (Class<?> mapType : MAP_TYPES) {
|
||||
if (mapType.isAssignableFrom(type)) {
|
||||
return true;
|
||||
}
|
||||
@@ -350,7 +361,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
@Nullable
|
||||
protected TypeInformation<?> doGetComponentType() {
|
||||
|
||||
var rawType = getType();
|
||||
Class<S> rawType = getType();
|
||||
|
||||
if (rawType.isArray()) {
|
||||
return createInfo(rawType.getComponentType());
|
||||
@@ -368,7 +379,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
return getTypeArgument(rawType, 0);
|
||||
}
|
||||
|
||||
var arguments = getTypeArguments();
|
||||
List<TypeInformation<?>> arguments = getTypeArguments();
|
||||
|
||||
return arguments.size() > 0 ? arguments.get(0) : null;
|
||||
}
|
||||
@@ -402,7 +413,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
}
|
||||
|
||||
List<Type> candidates = new ArrayList<>();
|
||||
var genericSuperclass = rawType.getGenericSuperclass();
|
||||
Type genericSuperclass = rawType.getGenericSuperclass();
|
||||
|
||||
if (genericSuperclass != null) {
|
||||
candidates.add(genericSuperclass);
|
||||
@@ -410,15 +421,15 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
candidates.addAll(Arrays.asList(rawType.getGenericInterfaces()));
|
||||
|
||||
for (var candidate : candidates) {
|
||||
for (Type candidate : candidates) {
|
||||
|
||||
var candidateInfo = createInfo(candidate);
|
||||
TypeInformation<?> candidateInfo = createInfo(candidate);
|
||||
|
||||
if (superType.equals(candidateInfo.getType())) {
|
||||
return candidateInfo;
|
||||
} else {
|
||||
|
||||
var nestedSuperType = candidateInfo.getSuperTypeInformation(superType);
|
||||
TypeInformation<?> nestedSuperType = candidateInfo.getSuperTypeInformation(superType);
|
||||
|
||||
if (nestedSuperType != null) {
|
||||
return nestedSuperType;
|
||||
@@ -435,7 +446,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
public boolean isAssignableFrom(TypeInformation<?> target) {
|
||||
|
||||
var superTypeInformation = target.getSuperTypeInformation(getType());
|
||||
TypeInformation<?> superTypeInformation = target.getSuperTypeInformation(getType());
|
||||
|
||||
return superTypeInformation == null ? false : superTypeInformation.equals(this);
|
||||
}
|
||||
@@ -448,7 +459,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
Assert.isTrue(getType().isAssignableFrom(type.getType()),
|
||||
() -> String.format("%s must be assignable from %s", getType(), type.getType()));
|
||||
|
||||
var typeArguments = getTypeArguments();
|
||||
List<TypeInformation<?>> typeArguments = getTypeArguments();
|
||||
|
||||
return (TypeInformation<? extends S>) (typeArguments.isEmpty() //
|
||||
? type //
|
||||
@@ -458,7 +469,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
@Nullable
|
||||
private TypeInformation<?> getTypeArgument(Class<?> bound, int index) {
|
||||
|
||||
var arguments = GenericTypeResolver.resolveTypeArguments(getType(), bound);
|
||||
Class<?>[] arguments = GenericTypeResolver.resolveTypeArguments(getType(), bound);
|
||||
|
||||
if (arguments != null) {
|
||||
return createInfo(arguments[index]);
|
||||
@@ -492,7 +503,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
return false;
|
||||
}
|
||||
|
||||
var that = (TypeDiscoverer<?>) obj;
|
||||
TypeDiscoverer<?> that = (TypeDiscoverer<?>) obj;
|
||||
|
||||
if (!this.type.equals(that.type)) {
|
||||
return false;
|
||||
@@ -517,7 +528,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
*/
|
||||
private boolean isCollection() {
|
||||
|
||||
var type = getType();
|
||||
Class<S> type = getType();
|
||||
|
||||
for (Class<?> collectionType : COLLECTION_TYPES) {
|
||||
if (collectionType.isAssignableFrom(type)) {
|
||||
@@ -538,7 +549,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
Assert.notNull(candidates, "Candidates must not be null!");
|
||||
|
||||
var type = getType();
|
||||
Class<S> type = getType();
|
||||
|
||||
for (Class<?> candidate : candidates) {
|
||||
if (candidate.equals(type)) {
|
||||
@@ -559,7 +570,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
Assert.notNull(candidates, "Candidates must not be null!");
|
||||
|
||||
var type = getType();
|
||||
Class<S> type = getType();
|
||||
|
||||
for (Class<?> candidate : candidates) {
|
||||
if (candidate.isAssignableFrom(type)) {
|
||||
@@ -604,9 +615,9 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
@Override
|
||||
public Type[] getActualTypeArguments() {
|
||||
|
||||
var result = new Type[typeParameters.size()];
|
||||
Type[] result = new Type[typeParameters.size()];
|
||||
|
||||
for (var i = 0; i < typeParameters.size(); i++) {
|
||||
for (int i = 0; i < typeParameters.size(); i++) {
|
||||
result[i] = typeParameters.get(i).getType();
|
||||
}
|
||||
|
||||
@@ -633,7 +644,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
var result = ObjectUtils.nullSafeHashCode(typeInformation);
|
||||
int result = ObjectUtils.nullSafeHashCode(typeInformation);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(typeParameters);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public interface TypeInformation<S> {
|
||||
*/
|
||||
default TypeInformation<?> getRequiredProperty(String property) {
|
||||
|
||||
var typeInformation = getProperty(property);
|
||||
TypeInformation<?> typeInformation = getProperty(property);
|
||||
|
||||
if (typeInformation != null) {
|
||||
return typeInformation;
|
||||
@@ -97,7 +97,7 @@ public interface TypeInformation<S> {
|
||||
*/
|
||||
default TypeInformation<?> getRequiredComponentType() {
|
||||
|
||||
var componentType = getComponentType();
|
||||
TypeInformation<?> componentType = getComponentType();
|
||||
|
||||
if (componentType != null) {
|
||||
return componentType;
|
||||
@@ -133,7 +133,7 @@ public interface TypeInformation<S> {
|
||||
*/
|
||||
default TypeInformation<?> getRequiredMapValueType() {
|
||||
|
||||
var mapValueType = getMapValueType();
|
||||
TypeInformation<?> mapValueType = getMapValueType();
|
||||
|
||||
if (mapValueType != null) {
|
||||
return mapValueType;
|
||||
@@ -191,7 +191,7 @@ public interface TypeInformation<S> {
|
||||
*/
|
||||
default TypeInformation<?> getRequiredActualType() {
|
||||
|
||||
var result = getActualType();
|
||||
TypeInformation<?> result = getActualType();
|
||||
|
||||
if (result == null) {
|
||||
throw new IllegalStateException(
|
||||
@@ -238,7 +238,7 @@ public interface TypeInformation<S> {
|
||||
*/
|
||||
default TypeInformation<?> getRequiredSuperTypeInformation(Class<?> superType) {
|
||||
|
||||
var result = getSuperTypeInformation(superType);
|
||||
TypeInformation<?> result = getSuperTypeInformation(superType);
|
||||
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
|
||||
@@ -67,7 +67,7 @@ class TypeVariableTypeInformation<T> extends ParentTypeAwareTypeInformation<T> {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
var result = 17;
|
||||
int result = 17;
|
||||
|
||||
result += 31 * nullSafeHashCode(getType());
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public class VavrCollectionConverters {
|
||||
@Override
|
||||
public Object convert(@Nullable Object source, TypeDescriptor sourceDescriptor, TypeDescriptor targetDescriptor) {
|
||||
|
||||
var targetType = targetDescriptor.getType();
|
||||
Class<?> targetType = targetDescriptor.getType();
|
||||
|
||||
if (io.vavr.collection.Seq.class.isAssignableFrom(targetType)) {
|
||||
return io.vavr.collection.List.ofAll((Iterable<?>) source);
|
||||
|
||||
@@ -68,12 +68,12 @@ public class Version implements Comparable<Version> {
|
||||
|
||||
Assert.hasText(version, "Version must not be null o empty!");
|
||||
|
||||
var parts = version.trim().split("\\.");
|
||||
var intParts = new int[parts.length];
|
||||
String[] parts = version.trim().split("\\.");
|
||||
int[] intParts = new int[parts.length];
|
||||
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
|
||||
var input = i == parts.length - 1 ? parts[i].replaceAll("\\D.*", "") : parts[i];
|
||||
String input = i == parts.length - 1 ? parts[i].replaceAll("\\D.*", "") : parts[i];
|
||||
|
||||
if (StringUtils.hasText(input)) {
|
||||
try {
|
||||
@@ -185,7 +185,7 @@ public class Version implements Comparable<Version> {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
var result = 17;
|
||||
int result = 17;
|
||||
result += 31 * major;
|
||||
result += 31 * minor;
|
||||
result += 31 * bugfix;
|
||||
|
||||
Reference in New Issue
Block a user