diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
index 57ddf078df9b..4b1f0457d8e1 100644
--- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
+++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
@@ -19,6 +19,7 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
+import java.lang.reflect.Parameter;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collection;
@@ -548,6 +549,18 @@ public String toString() {
}
+ /**
+ * Create a new type descriptor for the specified {@link Parameter}.
+ *
This is a convenience factory method for scenarios where a {@code Parameter}
+ * descriptor is already available.
+ * @param parameter the source parameter
+ * @return the corresponding type descriptor
+ * @since 7.1
+ */
+ public static TypeDescriptor forParameter(Parameter parameter) {
+ return new TypeDescriptor(MethodParameter.forParameter(parameter));
+ }
+
/**
* Create a new type descriptor for an object.
*
Use this factory method to introspect a source object before asking the
@@ -676,6 +689,32 @@ public static TypeDescriptor map(Class> mapType, @Nullable TypeDescriptor keyT
return new TypeDescriptor(methodParameter).nested(nestingLevel);
}
+ /**
+ * Create a type descriptor for a nested type declared within the parameter.
+ *
For example, if the parameter is a {@code List} and the
+ * nesting level is 1, the nested type descriptor will be {@code String.class}.
+ * If the parameter is a {@code List>} and the nesting
+ * level is 2, the nested type descriptor will also be a {@code String.class}.
+ * If the parameter is a {@code Map} and the nesting
+ * level is 1, the nested type descriptor will be String, derived from the map value.
+ * If the parameter is a {@code List