Consistent type variable resolution for arrays/collections (in particular at field level)
Deprecating GenericCollectionTypeResolver in favor of direct ResolvableType usage.
Issue: SPR-15160
(cherry picked from commit 5e946c2)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,8 +52,8 @@ public abstract class Conventions {
|
||||
private static final Set<Class<?>> IGNORED_INTERFACES;
|
||||
|
||||
static {
|
||||
IGNORED_INTERFACES = Collections.unmodifiableSet(new HashSet<Class<?>>(Arrays.<Class<?>>asList(
|
||||
Serializable.class, Externalizable.class, Cloneable.class, Comparable.class)));
|
||||
IGNORED_INTERFACES = Collections.unmodifiableSet(new HashSet<Class<?>>(
|
||||
Arrays.<Class<?>>asList(Serializable.class, Externalizable.class, Cloneable.class, Comparable.class)));
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public abstract class Conventions {
|
||||
pluralize = true;
|
||||
}
|
||||
else if (Collection.class.isAssignableFrom(parameter.getParameterType())) {
|
||||
valueClass = GenericCollectionTypeResolver.getCollectionParameterType(parameter);
|
||||
valueClass = ResolvableType.forMethodParameter(parameter).asCollection().resolveGeneric();
|
||||
if (valueClass == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot generate variable name for non-typed Collection parameter type");
|
||||
@@ -180,7 +180,7 @@ public abstract class Conventions {
|
||||
pluralize = true;
|
||||
}
|
||||
else if (Collection.class.isAssignableFrom(resolvedType)) {
|
||||
valueClass = GenericCollectionTypeResolver.getCollectionReturnType(method);
|
||||
valueClass = ResolvableType.forMethodReturnType(method).asCollection().resolveGeneric();
|
||||
if (valueClass == null) {
|
||||
if (!(value instanceof Collection)) {
|
||||
throw new IllegalArgumentException(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,9 @@ import java.util.Map;
|
||||
* @author Phillip Webb
|
||||
* @since 2.0
|
||||
* @see ResolvableType
|
||||
* @deprecated as of 4.3.6, in favor of direct {@link ResolvableType} usage
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class GenericCollectionTypeResolver {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,6 @@ import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
* @author Sam Brannen
|
||||
* @author Phillip Webb
|
||||
* @since 2.5.2
|
||||
* @see GenericCollectionTypeResolver
|
||||
*/
|
||||
public abstract class GenericTypeResolver {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,6 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Andy Clement
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
* @see GenericCollectionTypeResolver
|
||||
* @see org.springframework.core.annotation.SynthesizingMethodParameter
|
||||
*/
|
||||
public class MethodParameter {
|
||||
|
||||
Reference in New Issue
Block a user