package org.springframework.core;
Helper class that encapsulates the specification of a method parameter, i.e.
a Method or Constructor plus a parameter index and a nested type index for
a declared generic type. Useful as a specification object to pass along.
Map from Integer level to Integer type index
Create a new MethodParameter for the given method, with nesting level 1.
- Parameters:
method the Method to specify a parameter forparameterIndex the index of the parameter
this(method, parameterIndex, 1);
Create a new MethodParameter for the given method.
- Parameters:
method the Method to specify a parameter forparameterIndex the index of the parameter
(-1 for the method return type; 0 for the first method parameter,
1 for the second method parameter, etc)nestingLevel the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)
Assert.notNull(method, "Method must not be null");
Create a new MethodParameter for the given constructor, with nesting level 1.
- Parameters:
constructor the Constructor to specify a parameter forparameterIndex the index of the parameter
this(constructor, parameterIndex, 1);
Create a new MethodParameter for the given constructor.
- Parameters:
constructor the Constructor to specify a parameter forparameterIndex the index of the parameternestingLevel the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)
Assert.notNull(constructor, "Constructor must not be null");
Copy constructor, resulting in an independent MethodParameter object
based on the same metadata and cache state that the original object was in.
- Parameters:
original the original MethodParameter object to copy from
Assert.notNull(original, "Original must not be null");
this.method = original.method;
Return the wrapped Method, if any.
Note: Either Method or Constructor is available.
- Returns:
- the Method, or
null if none
Return the wrapped Constructor, if any.
Note: Either Method or Constructor is available.
- Returns:
- the Constructor, or
null if none
Return the class that declares the underlying Method or Constructor.
Return the index of the method/constructor parameter.
- Returns:
- the parameter index (never negative)
Set a resolved (generic) parameter type.
Return the type of the method/constructor parameter.
- Returns:
- the parameter type (never
null)
Return the generic type of the method/constructor parameter.
- Returns:
- the parameter type (never
null)
Return the annotations associated with the target method/constructor itself.
Return the method/constructor annotation of the given type, if available.
- Parameters:
annotationType the annotation type to look for- Returns:
- the annotation object, or
null if not found
Return the annotations associated with the specific method/constructor parameter.
Return the parameter annotation of the given type, if available.
- Parameters:
annotationType the annotation type to look for- Returns:
- the annotation object, or
null if not found
Initialize parameter name discovery for this method parameter.
This method does not actually try to retrieve the parameter name at
this point; it just allows discovery to happen when the application calls
getParameterName() (if ever).
Return the name of the method/constructor parameter.
- Returns:
- the parameter name (may be
null if no
parameter name metadata is contained in the class file or no
ParameterNameDiscoverer
has been set to begin with)
if (parameterNames != null) { Increase this parameter's nesting level.
Decrease this parameter's nesting level.
Return the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List).
Set the type index for the current nesting level.
- Parameters:
typeIndex the corresponding type index
(or null for the default type index)- See also:
getNestingLevel()
Return the type index for the current nesting level.
- Returns:
- the corresponding type index, or
null
if none specified (indicating the default type index) - See also:
getNestingLevel()
Return the type index for the specified nesting level.
- Parameters:
nestingLevel the nesting level to check- Returns:
- the corresponding type index, or
null
if none specified (indicating the default type index)
Obtain the (lazily constructed) type-indexes-per-level Map.
Create a new MethodParameter for the given method or constructor.
This is a convenience constructor for scenarios where a
Method or Constructor reference is treated in a generic fashion.
- Parameters:
methodOrConstructor the Method or Constructor to specify a parameter forparameterIndex the index of the parameter- Returns:
- the corresponding MethodParameter instance
if (methodOrConstructor instanceof Method) { "Given object [" + methodOrConstructor + "] is neither a Method nor a Constructor");