The Spring Framework

org.springframework.core
Class MethodParameter

java.lang.Object
  extended by org.springframework.core.MethodParameter

public class MethodParameter
extends Object

Helper class that encapsulates the specification of a method parameter, that is, a Method or Constructor plus a parameter index. Useful as a specification object to pass along.

Used by GenericCollectionTypeResolver, BeanWrapperImpl and AbstractBeanFactory.

Since:
2.0
Author:
Juergen Hoeller
See Also:
GenericCollectionTypeResolver, BeanWrapperImpl, AbstractBeanFactory

Constructor Summary
MethodParameter(Constructor constructor, int parameterIndex)
          Create a new MethodParameter for the given constructor.
MethodParameter(Method method, int parameterIndex)
          Create a new MethodParameter for the given method.
 
Method Summary
static MethodParameter forMethodOrConstructor(Object methodOrConstructor, int parameterIndex)
          Create a new MethodParameter for the given method or constructor.
 Constructor getConstructor()
          Return the Constructor held, if any.
 Method getMethod()
          Return the Method held, if any.
 int getParameterIndex()
          Return the index of the method/constructor parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodParameter

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

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

MethodParameter

public MethodParameter(Constructor constructor,
                       int parameterIndex)
Create a new MethodParameter for the given constructor.

Parameters:
constructor - the Constructor to specify a parameter for
parameterIndex - the index of the parameter
Method Detail

getMethod

public Method getMethod()
Return the Method held, if any.

Note: Either Method or Constructor is available.

Returns:
the Method, or null if none

getConstructor

public Constructor getConstructor()
Return the Constructor held, if any.

Note: Either Method or Constructor is available.

Returns:
the Constructor, or null if none

getParameterIndex

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

Returns:
the parameter index (never negative)

forMethodOrConstructor

public static MethodParameter forMethodOrConstructor(Object methodOrConstructor,
                                                     int parameterIndex)
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 for
parameterIndex - the index of the parameter

The Spring Framework

Copyright © 2002-2006 The Spring Framework.