public class ReflectUtils extends Object
Constructor and Description |
---|
ReflectUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> Constructor<T> |
getPrivateConstructor(Class<T> c,
Class<?>... args)
Look up a private constructor and make it accessible for testing.
|
static <T> Field |
getPrivateField(Class<?> c,
String fieldName)
Look up a private field and make it accessible for testing.
|
static Method |
getPrivateMethod(Class<?> c,
String name,
Class<?>... args)
Look up a private method and make it accessible for testing.
|
static void |
testUtilityConstructor(Class c)
Method for testing the constructor of a utility class (the constructor should be private).
|
public ReflectUtils()
public static Method getPrivateMethod(Class<?> c, String name, Class<?>... args) throws NoSuchMethodException
c
- Class to look in.name
- Name of the method.args
- Arguments for the method. Note that primitive types are found using XXX.TYPE.NoSuchMethodException
public static <T> Field getPrivateField(Class<?> c, String fieldName) throws NoSuchFieldException
c
- The class that declares the field.fieldName
- The name of the field.NoSuchFieldException
- If there is no such field declared in the class.public static <T> Constructor<T> getPrivateConstructor(Class<T> c, Class<?>... args) throws NoSuchMethodException
c
- Class to look in.args
- Arguments for the constructor. Note that primitive types are found using XXX.TYPE.NoSuchMethodException
public static void testUtilityConstructor(Class c)
Copyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.