|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jayway.awaitility.reflect.WhiteboxImpl
public class WhiteboxImpl
Various utilities for accessing internals of a class. Basically a simplified reflection utility. Copied with permission from PowerMock project.
Constructor Summary | |
---|---|
WhiteboxImpl()
|
Method Summary | ||
---|---|---|
static
|
getByNameAndType(Object object,
String fieldName,
Class<T> expectedFieldType)
|
|
static Field |
getFieldAnnotatedWith(Object object,
Class<? extends Annotation> annotationType)
Get field annotated with a particular annotation. |
|
static
|
getInternalState(Object object,
Class<T> fieldType)
Get the value of a field using reflection. |
|
static
|
getInternalState(Object object,
String fieldName)
Get the value of a field using reflection. |
|
static Class<?> |
getType(Object object)
Gets the type. |
|
static boolean |
isClass(Object argument)
Checks if is class. |
|
static void |
throwExceptionIfFieldWasNotFound(Class<?> type,
String fieldName,
Field field)
Throw exception if field was not found. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WhiteboxImpl()
Method Detail |
---|
public static <T> T getInternalState(Object object, String fieldName)
T
- the generic typeobject
- the object to modifyfieldName
- the name of the field
#getInternalState(Object, String, Class)
.public static <T> T getInternalState(Object object, Class<T> fieldType)
T
- the generic typeobject
- the object to modifyfieldType
- the type of the field
public static void throwExceptionIfFieldWasNotFound(Class<?> type, String fieldName, Field field)
type
- the typefieldName
- the field namefield
- the fieldpublic static Class<?> getType(Object object)
object
- the object
public static Field getFieldAnnotatedWith(Object object, Class<? extends Annotation> annotationType)
object
- The object to look for annotations. Note that if're you're
passing an object only instance fields are checked, passing a
class will only check static fields.annotationTypes
- The annotation types to look for
public static boolean isClass(Object argument)
argument
- the argument
public static <T> T getByNameAndType(Object object, String fieldName, Class<T> expectedFieldType)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |