org.constretto.internal
Class MethodParameter

java.lang.Object
  extended by org.constretto.internal.MethodParameter

public class MethodParameter
extends java.lang.Object

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.

Since:
2.0
Author:
Juergen Hoeller, Rob Harrop, Andy Clement
See Also:
GenericCollectionTypeResolver

Constructor Summary
MethodParameter(java.lang.reflect.Method method, int parameterIndex)
          Create a new MethodParameter for the given method, with nesting level 1.
MethodParameter(java.lang.reflect.Method method, int parameterIndex, int nestingLevel)
          Create a new MethodParameter for the given method.
 
Method Summary
 java.lang.reflect.Constructor getConstructor()
          Return the wrapped Constructor, if any.
 java.lang.Class getDeclaringClass()
          Return the class that declares the underlying Method or Constructor.
 java.lang.reflect.Method getMethod()
          Return the wrapped Method, if any.
 java.lang.annotation.Annotation[] getMethodAnnotations()
          Return the annotations associated with the target method/constructor itself.
 int getNestingLevel()
          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).
 java.lang.annotation.Annotation[] getParameterAnnotations()
          Return the annotations associated with the specific method/constructor parameter.
 int getParameterIndex()
          Return the index of the method/constructor parameter.
 java.lang.Class<?> getParameterType()
          Return the type of the method/constructor parameter.
 java.lang.Integer getTypeIndexForLevel(int nestingLevel)
          Return the type index for the specified nesting level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodParameter

public MethodParameter(java.lang.reflect.Method method,
                       int parameterIndex)
Create a new MethodParameter for the given method, with nesting level 1.

Parameters:
method - the Method to specify a parameter for
parameterIndex - the index of the parameter

MethodParameter

public MethodParameter(java.lang.reflect.Method method,
                       int parameterIndex,
                       int nestingLevel)
Create a new MethodParameter for the given method.

Parameters:
method - the Method to specify a parameter for
parameterIndex - 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)
Method Detail

getMethod

public java.lang.reflect.Method getMethod()
Return the wrapped Method, if any.

Note: Either Method or Constructor is available.

Returns:
the Method, or null if none

getConstructor

public java.lang.reflect.Constructor getConstructor()
Return the wrapped Constructor, if any.

Note: Either Method or Constructor is available.

Returns:
the Constructor, or null if none

getDeclaringClass

public java.lang.Class getDeclaringClass()
Return the class that declares the underlying Method or Constructor.


getParameterIndex

public int getParameterIndex()
Return the index of the method/constructor parameter.

Returns:
the parameter index (never negative)

getParameterType

public java.lang.Class<?> getParameterType()
Return the type of the method/constructor parameter.

Returns:
the parameter type (never null)

getMethodAnnotations

public java.lang.annotation.Annotation[] getMethodAnnotations()
Return the annotations associated with the target method/constructor itself.


getParameterAnnotations

public java.lang.annotation.Annotation[] getParameterAnnotations()
Return the annotations associated with the specific method/constructor parameter.


getNestingLevel

public int getNestingLevel()
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).


getTypeIndexForLevel

public java.lang.Integer getTypeIndexForLevel(int nestingLevel)
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)


Copyright © 2008-2011. All Rights Reserved.