joptsimple.internal
Class Reflection

java.lang.Object
  extended by joptsimple.internal.Reflection

public class Reflection
extends java.lang.Object

Helper methods for reflection.

Since:
2.0
Version:
$Id: Reflection.java,v 1.1 2008/04/01 21:46:46 pholser Exp $
Author:
Paul Holser

Constructor Summary
protected Reflection()
           
 
Method Summary
static java.lang.reflect.Member findConverter(java.lang.Class clazz)
          Finds an appropriate value converter for the given class.
private static java.lang.reflect.Constructor findConverterConstructor(java.lang.Class clazz)
           
private static java.lang.reflect.Method findConverterMethod(java.lang.Class clazz)
           
static java.lang.Object invokeQuietly(java.lang.reflect.Constructor constructor, java.lang.Object[] args)
          Invokes the given constructor with the given args.
static java.lang.Object invokeStaticQuietly(java.lang.reflect.Method method, java.lang.Object[] args)
          Invokes the given static method with the given args.
private static boolean matchesConverterRequirements(java.lang.reflect.Method method, java.lang.Class expectedReturnType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reflection

protected Reflection()
Method Detail

findConverter

public static java.lang.reflect.Member findConverter(java.lang.Class clazz)
Finds an appropriate value converter for the given class.

Parameters:
clazz - class to introspect on
Returns:
a converter method or constructor

findConverterMethod

private static java.lang.reflect.Method findConverterMethod(java.lang.Class clazz)

matchesConverterRequirements

private static boolean matchesConverterRequirements(java.lang.reflect.Method method,
                                                    java.lang.Class expectedReturnType)

findConverterConstructor

private static java.lang.reflect.Constructor findConverterConstructor(java.lang.Class clazz)

invokeQuietly

public static java.lang.Object invokeQuietly(java.lang.reflect.Constructor constructor,
                                             java.lang.Object[] args)
Invokes the given constructor with the given args.

Parameters:
constructor - constructor to invoke
args - arguments to hand to the constructor
Returns:
the result of invoking the constructor
Throws:
ReflectionException - in lieu of the gaggle of reflection-related exceptions

invokeStaticQuietly

public static java.lang.Object invokeStaticQuietly(java.lang.reflect.Method method,
                                                   java.lang.Object[] args)
Invokes the given static method with the given args.

Parameters:
method - method to invoke
args - arguments to hand to the method
Returns:
the result of invoking the method
Throws:
ReflectionException - in lieu of the gaggle of reflection-related exceptions