Top Description Constructors Methods
joptsimple.internal

public final Class Reflection

extends Object
Class Inheritance
Imports
java.lang.reflect.Constructor, .InvocationTargetException, .Method, joptsimple.ValueConverter

Helper methods for reflection.
Author
Paul Holser

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static <V> ValueConverter<V>
public static <V> V
convertWith(ValueConverter<V> converter, String raw)

public static <
a constraint on the class object to introspect
V
>
ValueConverter<V>

Returns:

a converter method or constructor
findConverter
(Class<V>
class to introspect on
clazz
)

Finds an appropriate value converter for the given class.

public static <
constraint on the type of the objects yielded by the constructor
T
>
T

Returns:

the result of invoking the constructor
instantiate
(Constructor<T>
constructor to invoke
constructor
,
Object...
arguments to hand to the constructor
args
)

Invokes the given constructor with the given arguments.

public static Object

Returns:

the result of invoking the method
invoke
(Method
method to invoke
method
,
Object...
arguments to hand to the method
args
)

Invokes the given static method with the given arguments.

private static boolean
meetsConverterRequirements(Method method, Class<?> expectedReturnType)

private static RuntimeException
private static <V> ValueConverter<V>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Reflectionback to summary
private Reflection()

Method Detail

constructorConverterback to summary
private static <V> ValueConverter<V> constructorConverter(Class<V> clazz)
convertWithback to summary
public static <V> V convertWith(ValueConverter<V> converter, String raw)
Annotations
@SuppressWarnings:unchecked
findConverterback to summary
public static <V> ValueConverter<V> findConverter(Class<V> clazz)

Finds an appropriate value converter for the given class.

Parameters
<V>
a constraint on the class object to introspect
clazz:Class<V>

class to introspect on

Returns:ValueConverter<V>

a converter method or constructor

instantiateback to summary
public static <T> T instantiate(Constructor<T> constructor, Object... args)

Invokes the given constructor with the given arguments.

Parameters
<T>
constraint on the type of the objects yielded by the constructor
constructor:Constructor<T>

constructor to invoke

args:Object[]

arguments to hand to the constructor

Returns:T

the result of invoking the constructor

Exceptions
ReflectionException:
in lieu of the gaggle of reflection-related exceptions
invokeback to summary
public static Object invoke(Method method, Object... args)

Invokes the given static method with the given arguments.

Parameters
method:Method

method to invoke

args:Object[]

arguments to hand to the method

Returns:Object

the result of invoking the method

Exceptions
ReflectionException:
in lieu of the gaggle of reflection-related exceptions
meetsConverterRequirementsback to summary
private static boolean meetsConverterRequirements(Method method, Class<?> expectedReturnType)
reflectionExceptionback to summary
private static RuntimeException reflectionException(Exception ex)
valueOfConverterback to summary
private static <V> ValueConverter<V> valueOfConverter(Class<V> clazz)