public class Fields extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<Field> |
getAllDeclaredFieldsOptional(Class<?> type)
Returns an unmodifiable list containing all fields of that are returned
by a call to
Class.getDeclaredFields() on the given type or any
of its supertypes. |
static List<Field> |
getAllDeclaredFieldsUnchecked(Class<?> type)
Returns an unmodifiable list containing all fields of that are returned
by a call to
Class.getDeclaredFields() on the given type or any
of its supertypes. |
static List<Field> |
getAllOptional(Class<?> type,
Predicate<? super Field>... predicates)
Returns an unmodifiable list containing all fields of the given type
that match the given predicates.
|
static List<Field> |
getAllUnchecked(Class<?> type,
Predicate<? super Field>... predicates)
Returns an unmodifiable list containing all fields of the given type
that match the given predicates.
|
static boolean |
getBooleanNonAccessibleOptional(Field field,
Object object,
boolean defaultValue)
Get the value of the given field in the given object.
|
static boolean |
getBooleanNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
boolean |
getBooleanOptional(Field field,
Object object,
boolean defaultValue)
Get the value of the given field in the given object.
|
boolean |
getBooleanUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static byte |
getByteNonAccessibleOptional(Field field,
Object object,
byte defaultValue)
Get the value of the given field in the given object.
|
static byte |
getByteNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
byte |
getByteOptional(Field field,
Object object,
byte defaultValue)
Get the value of the given field in the given object.
|
byte |
getByteUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static char |
getCharNonAccessibleOptional(Field field,
Object object,
char defaultValue)
Get the value of the given field in the given object.
|
static char |
getCharNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
char |
getCharOptional(Field field,
Object object,
char defaultValue)
Get the value of the given field in the given object.
|
char |
getCharUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static Field |
getDeclaredFieldOptional(Class<?> type,
String fieldName)
|
static List<Field> |
getDeclaredFieldsOptional(Class<?> type)
Returns an unmodifiable List containing all fields that result
from a call to
Class.getDeclaredFields(). |
static List<Field> |
getDeclaredFieldsUnchecked(Class<?> type)
Returns an unmodifiable List containing all fields that result
from a call to
Class.getDeclaredFields()This call covers the following fields: public, protected, default, and private fields static and instance fields excluding fields from supertypes This call is wrapping all possible checked exceptions and SecurityExceptions into a ReflectionException |
static Field |
getDeclaredFieldUnchecked(Class<?> type,
String fieldName)
|
static double |
getDoubleNonAccessibleOptional(Field field,
Object object,
double defaultValue)
Get the value of the given field in the given object.
|
static double |
getDoubleNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
double |
getDoubleOptional(Field field,
Object object,
double defaultValue)
Get the value of the given field in the given object.
|
double |
getDoubleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static Field |
getFieldOptional(Class<?> type,
String fieldName)
Calls
Class.getField(String). |
static List<Field> |
getFieldsOptional(Class<?> type)
Returns an unmodifiable List containing all fields that result
from a call to
Class.getFields(). |
static List<Field> |
getFieldsUnchecked(Class<?> type)
Returns an unmodifiable List containing all fields that result
from a call to
Class.getFields(). |
static Field |
getFieldUnchecked(Class<?> type,
String fieldName)
Calls
Class.getField(String). |
static float |
getFloatNonAccessibleOptional(Field field,
Object object,
float defaultValue)
Get the value of the given field in the given object.
|
static float |
getFloatNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
float |
getFloatOptional(Field field,
Object object,
float defaultValue)
Get the value of the given field in the given object.
|
float |
getFloatUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static int |
getIntNonAccessibleOptional(Field field,
Object object,
int defaultValue)
Get the value of the given field in the given object.
|
static int |
getIntNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
int |
getIntOptional(Field field,
Object object,
int defaultValue)
Get the value of the given field in the given object.
|
int |
getIntUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static long |
getLongNonAccessibleOptional(Field field,
Object object,
long defaultValue)
Get the value of the given field in the given object.
|
static long |
getLongNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
long |
getLongOptional(Field field,
Object object,
long defaultValue)
Get the value of the given field in the given object.
|
long |
getLongUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static Object |
getNonAccessibleOptional(Field field,
Object object)
Get the value of the given field in the given object.
|
static Object |
getNonAccessibleOptional(Field field,
Object object,
Object defaultValue)
Get the value of the given field in the given object.
|
static Object |
getNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
Object |
getOptional(Field field,
Object object)
Get the value of the given field in the given object.
|
Object |
getOptional(Field field,
Object object,
Object defaultValue)
Get the value of the given field in the given object.
|
static List<Field> |
getOwnFieldsOptional(Class<?> type)
Returns an unmodifiable list containing all fields of that are returned
by a call to
Class.getFields() on the given type, except for
those that are inherited from any supertype. |
static List<Field> |
getOwnFieldsUnchecked(Class<?> type)
Returns an unmodifiable list containing all fields of that are returned
by a call to
Class.getFields() on the given type, except for
those that are inherited from any supertype. |
static short |
getShortNonAccessibleOptional(Field field,
Object object,
short defaultValue)
Get the value of the given field in the given object.
|
static short |
getShortNonAccessibleUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
short |
getShortOptional(Field field,
Object object,
short defaultValue)
Get the value of the given field in the given object.
|
short |
getShortUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
Object |
getUnchecked(Field field,
Object object)
Get the value of the given field in the given object.
|
static void |
setNonAccessibleOptional(Field field,
Object object,
Object value)
Set the value for the given field in the given object.
|
static void |
setNonAccessibleUnchecked(Field field,
Object object,
Object value)
Set the value for the given field in the given object.
|
void |
setOptional(Field field,
Object object,
Object value)
Set the value for the given field in the given object.
|
void |
setUnchecked(Field field,
Object object,
Object value)
Set the value for the given field in the given object.
|
public static Field getFieldUnchecked(Class<?> type, String fieldName)
Class.getField(String).ReflectionExceptiontype - The typefieldName - The field nameReflectionException - if the call did not succeedpublic static Field getFieldOptional(Class<?> type, String fieldName)
Class.getField(String).null if the underlying call did not succeed.type - The typefieldName - The field namenull if it could not be obtainedpublic static Field getDeclaredFieldUnchecked(Class<?> type, String fieldName)
Class.getDeclaredField(String).ReflectionExceptiontype - The typefieldName - The field nameReflectionException - if the call did not succeedpublic static Field getDeclaredFieldOptional(Class<?> type, String fieldName)
Class.getDeclaredField(String).null if the underlying call did not succeed.type - The typefieldName - The field namenull otherwise.public static List<Field> getFieldsUnchecked(Class<?> type)
Class.getFields().ReflectionExceptiontype - The typeReflectionException - if the call did not succeedpublic static List<Field> getFieldsOptional(Class<?> type)
Class.getFields(). type - The typepublic static List<Field> getDeclaredFieldsUnchecked(Class<?> type)
Class.getDeclaredFields()ReflectionExceptiontype - The typeReflectionException - if the call did not succeedpublic static List<Field> getDeclaredFieldsOptional(Class<?> type)
Class.getDeclaredFields().type - The typepublic static List<Field> getAllDeclaredFieldsUnchecked(Class<?> type)
Class.getDeclaredFields() on the given type or any
of its supertypes.ReflectionExceptiontype - The typeReflectionException - if the call did not succeed.public static List<Field> getAllDeclaredFieldsOptional(Class<?> type)
Class.getDeclaredFields() on the given type or any
of its supertypes.type - The typepublic static List<Field> getOwnFieldsUnchecked(Class<?> type)
Class.getFields() on the given type, except for
those that are inherited from any supertype.ReflectionExceptiontype - The typeReflectionException - if the call did not succeed.public static List<Field> getOwnFieldsOptional(Class<?> type)
Class.getFields() on the given type, except for
those that are inherited from any supertype.type - The type@SafeVarargs public static List<Field> getAllOptional(Class<?> type, Predicate<? super Field>... predicates)
getAllDeclaredFieldsOptional(Class) with the given
predicates.type - The typepredicates - The predicates@SafeVarargs public static List<Field> getAllUnchecked(Class<?> type, Predicate<? super Field>... predicates)
getAllDeclaredFieldsUnchecked(Class) with the given
predicates.ReflectionExceptiontype - The typepredicates - The predicatesReflectionException - if the call did not succeedpublic void setUnchecked(Field field, Object object, Object value)
ReflectionExceptionfield - The fieldobject - The objectvalue - The valueReflectionException - if the call did not succeedpublic static void setNonAccessibleUnchecked(Field field, Object object, Object value)
ReflectionExceptionfield - The fieldobject - The objectvalue - The valueReflectionException - if the call did not succeedpublic void setOptional(Field field, Object object, Object value)
field - The fieldobject - The objectvalue - The valuepublic static void setNonAccessibleOptional(Field field, Object object, Object value)
field - The fieldobject - The objectvalue - The valuepublic Object getUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static Object getNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic Object getOptional(Field field, Object object)
null if the underlying call did not succeed.field - The fieldobject - The objectpublic static Object getNonAccessibleOptional(Field field, Object object)
null if the underlying call did not succeed.field - The fieldobject - The objectpublic Object getOptional(Field field, Object object, Object defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static Object getNonAccessibleOptional(Field field, Object object, Object defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic boolean getBooleanUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static boolean getBooleanNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic boolean getBooleanOptional(Field field, Object object, boolean defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static boolean getBooleanNonAccessibleOptional(Field field, Object object, boolean defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic byte getByteUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static byte getByteNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic byte getByteOptional(Field field, Object object, byte defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static byte getByteNonAccessibleOptional(Field field, Object object, byte defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic short getShortUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static short getShortNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic short getShortOptional(Field field, Object object, short defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static short getShortNonAccessibleOptional(Field field, Object object, short defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic char getCharUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static char getCharNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic char getCharOptional(Field field, Object object, char defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static char getCharNonAccessibleOptional(Field field, Object object, char defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic int getIntUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static int getIntNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic int getIntOptional(Field field, Object object, int defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static int getIntNonAccessibleOptional(Field field, Object object, int defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic long getLongUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static long getLongNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic long getLongOptional(Field field, Object object, long defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static long getLongNonAccessibleOptional(Field field, Object object, long defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic float getFloatUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static float getFloatNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic float getFloatOptional(Field field, Object object, float defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static float getFloatNonAccessibleOptional(Field field, Object object, float defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic double getDoubleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic static double getDoubleNonAccessibleUnchecked(Field field, Object object)
ReflectionExceptionfield - The fieldobject - The objectReflectionException - if the call did not succeedpublic double getDoubleOptional(Field field, Object object, double defaultValue)
field - The fieldobject - The objectdefaultValue - The default valuepublic static double getDoubleNonAccessibleOptional(Field field, Object object, double defaultValue)
field - The fieldobject - The objectdefaultValue - The default valueCopyright © 2018. All rights reserved.