public class WhiteboxImpl extends Object
Constructor and Description |
---|
WhiteboxImpl() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
getByNameAndType(Object object,
String fieldName,
Class<T> expectedFieldType)
getByNameAndType.
|
static Field |
getFieldAnnotatedWith(Object object,
Class<? extends Annotation> annotationType)
Get field annotated with a particular annotation.
|
static <T> T |
getInternalState(Object object,
Class<T> fieldType)
Get the value of a field using reflection.
|
static <T> T |
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.
|
public static <T> T getInternalState(Object object, String fieldName)
T
- the generic typeobject
- the object to modifyfieldName
- the name of the fieldpublic static <T> T getInternalState(Object object, Class<T> fieldType)
T
- the generic typeobject
- the object to modifyfieldType
- the type of the fieldpublic static void throwExceptionIfFieldWasNotFound(Class<?> type, String fieldName, Field field)
type
- the typefieldName
- the field namefield
- the fieldpublic static Class<?> getType(Object object)
object
- the objectpublic 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.annotationType
- The annotation types to look forpublic static boolean isClass(Object argument)
argument
- the argumentCopyright © 2010–2022. All rights reserved.