org.compass.core.util.reflection.plain
Class PlainReflectionMethod<T>

java.lang.Object
  extended by org.compass.core.util.reflection.plain.PlainReflectionMethod<T>
All Implemented Interfaces:
ReflectionMethod

public class PlainReflectionMethod<T>
extends Object
implements ReflectionMethod

A plain implemenation of ReflectionMethod that simply delegates operations to Method.

Author:
kimchy

Constructor Summary
PlainReflectionMethod(Method method)
           
 
Method Summary
<A extends Annotation>
A
getAnnotation(Class<A> annotationType)
          Returns this element's annotation for the specified type if such an annotation is present, else null.
 Class<?> getDeclaringClass()
          Returns the Class object representing the class or interface that declares the member or constructor represented by this Member.
 Class[] getExceptionTypes()
          Returns an array of Class objects that represent the types of the exceptions declared to be thrown by the underlying method represented by this IMethod object.
 Type getGenericReturnType()
          Returns a Type object that represents the formal return type of the method represented by this Method object.
 Method getMethod()
          Return a reference to the Method that this ReflectionMethod represent.
 int getModifiers()
          Returns the Java language modifiers for the member or constructor represented by this Member, as an integer.
 String getName()
          Returns the simple name of the underlying member or constructor represented by this Member.
 Class<?>[] getParameterTypes()
          Returns an array of Class objects that represent the formal parameter types, in declaration order, of the method represented by this Method object.
 Class<?> getReturnType()
          Returns a Class object that represents the formal return type of the method represented by this IMethod object.
 Object invoke(Object obj, Object... args)
          Invokes the underlying method represented by this IMethod object, on the specified object with the specified parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlainReflectionMethod

public PlainReflectionMethod(Method method)
Method Detail

getDeclaringClass

public Class<?> getDeclaringClass()
Description copied from interface: ReflectionMethod
Returns the Class object representing the class or interface that declares the member or constructor represented by this Member.

Specified by:
getDeclaringClass in interface ReflectionMethod
Returns:
an object representing the declaring class of the underlying member

getName

public String getName()
Description copied from interface: ReflectionMethod
Returns the simple name of the underlying member or constructor represented by this Member.

Specified by:
getName in interface ReflectionMethod
Returns:
the simple name of the underlying member

getModifiers

public int getModifiers()
Description copied from interface: ReflectionMethod
Returns the Java language modifiers for the member or constructor represented by this Member, as an integer. The Modifier class should be used to decode the modifiers in the integer.

Specified by:
getModifiers in interface ReflectionMethod
Returns:
the Java language modifiers for the underlying member
See Also:
Modifier

getReturnType

public Class<?> getReturnType()
Description copied from interface: ReflectionMethod
Returns a Class object that represents the formal return type of the method represented by this IMethod object.

Specified by:
getReturnType in interface ReflectionMethod
Returns:
the return type for the method this object represents

getParameterTypes

public Class<?>[] getParameterTypes()
Description copied from interface: ReflectionMethod
Returns an array of Class objects that represent the formal parameter types, in declaration order, of the method represented by this Method object. Returns an array of length 0 if the underlying method takes no parameters.

Specified by:
getParameterTypes in interface ReflectionMethod
Returns:
the parameter types for the method this object represents

getExceptionTypes

public Class[] getExceptionTypes()
Description copied from interface: ReflectionMethod
Returns an array of Class objects that represent the types of the exceptions declared to be thrown by the underlying method represented by this IMethod object. Returns an array of length 0 if the method declares no exceptions in its throws clause.

Specified by:
getExceptionTypes in interface ReflectionMethod
Returns:
the exception types declared as being thrown by the method this object represents

getAnnotation

public <A extends Annotation> A getAnnotation(Class<A> annotationType)
Description copied from interface: ReflectionMethod
Returns this element's annotation for the specified type if such an annotation is present, else null.

Specified by:
getAnnotation in interface ReflectionMethod
Parameters:
annotationType - the Class object corresponding to the annotation type
Returns:
this element's annotation for the specified annotation type if present on this element, else null

getGenericReturnType

public Type getGenericReturnType()
Description copied from interface: ReflectionMethod
Returns a Type object that represents the formal return type of the method represented by this Method object.

If the return type is a parameterized type, the Type object returned must accurately reflect the actual type parameters used in the source code.

If the return type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.

Specified by:
getGenericReturnType in interface ReflectionMethod
Returns:
a Type object that represents the formal return type of the underlying method

invoke

public Object invoke(Object obj,
                     Object... args)
              throws IllegalAccessException,
                     IllegalArgumentException,
                     InvocationTargetException
Description copied from interface: ReflectionMethod
Invokes the underlying method represented by this IMethod object, on the specified object with the specified parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to method invocation conversions as necessary.

Specified by:
invoke in interface ReflectionMethod
Parameters:
obj - the object the underlying method is invoked from
args - the arguments used for the method call
Returns:
the result of dispatching the method represented by this object on obj with parameters args
Throws:
IllegalAccessException - if this Method object enforces Java language access control and the underlying method is inaccessible.
IllegalArgumentException - if the method is an instance method and the specified object argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.
InvocationTargetException - if the underlying method throws an exception.

getMethod

public Method getMethod()
Description copied from interface: ReflectionMethod
Return a reference to the Method that this ReflectionMethod represent.

Specified by:
getMethod in interface ReflectionMethod


Copyright (c) 2004-2009 The Compass Project.