public class Fields
extends java.lang.Object
| Constructor and Description |
|---|
Fields() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
copy(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the value of the field from one instance to another.
|
static void |
copyBoolean(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the boolean value of the field from one instance to another.
|
static void |
copyByte(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the byte value of the field from one instance to another.
|
static void |
copyChar(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the char value of the field from one instance to another.
|
static void |
copyDouble(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the double value of the field from one instance to another.
|
static void |
copyFloat(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the float value of the field from one instance to another.
|
static void |
copyInt(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the int value of the field from one instance to another.
|
static void |
copyLong(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the long value of the field from one instance to another.
|
static void |
copyObject(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the value of the field from one instance to another.
|
static void |
copyShort(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
Copy the short value of the field from one instance to another.
|
static <T> T |
get(java.lang.Object instance,
java.lang.reflect.Field field)
Get the value of a field.
|
static boolean |
getBoolean(java.lang.Object instance,
java.lang.reflect.Field field)
Get the boolean value of a field.
|
static byte |
getByte(java.lang.Object instance,
java.lang.reflect.Field field)
Get the byte value of a field.
|
static char |
getChar(java.lang.Object instance,
java.lang.reflect.Field field)
Get the char value of a field.
|
static java.lang.reflect.Field |
getDeclaredField(java.lang.Class<?> clazz,
java.lang.String name)
Get a declared field of a class by its name.
|
static java.lang.reflect.Field[] |
getDeclaredFields(java.lang.Class<?> clazz)
Get all declared fields of a class.
|
static double |
getDouble(java.lang.Object instance,
java.lang.reflect.Field field)
Get the double value of a field.
|
static float |
getFloat(java.lang.Object instance,
java.lang.reflect.Field field)
Get the float value of a field.
|
static int |
getInt(java.lang.Object instance,
java.lang.reflect.Field field)
Get the int value of a field.
|
static long |
getLong(java.lang.Object instance,
java.lang.reflect.Field field)
Get the long value of a field.
|
static <T> T |
getObject(java.lang.Object instance,
java.lang.reflect.Field field)
Get the value of a field.
|
static short |
getShort(java.lang.Object instance,
java.lang.reflect.Field field)
Get the short value of a field.
|
static java.lang.Object |
instance(java.lang.Object instance,
java.lang.reflect.Field field)
Get the instance used for getting/setting the value of the field using unsafe.
|
static long |
offset(java.lang.reflect.Field field)
Get the offset of a field required for getting/setting the value of the field using unsafe.
|
static <T> void |
set(java.lang.Object instance,
java.lang.reflect.Field field,
T value)
Set the value of a field.
|
static void |
setBoolean(java.lang.Object instance,
java.lang.reflect.Field field,
boolean value)
Set the boolean value of a field.
|
static void |
setByte(java.lang.Object instance,
java.lang.reflect.Field field,
byte value)
Set the byte value of a field.
|
static void |
setChar(java.lang.Object instance,
java.lang.reflect.Field field,
char value)
Set the char value of a field.
|
static void |
setDouble(java.lang.Object instance,
java.lang.reflect.Field field,
double value)
Get the double value of a field.
|
static void |
setFloat(java.lang.Object instance,
java.lang.reflect.Field field,
float value)
Set the float value of a field.
|
static void |
setInt(java.lang.Object instance,
java.lang.reflect.Field field,
int value)
Set the int value of a field.
|
static void |
setLong(java.lang.Object instance,
java.lang.reflect.Field field,
long value)
Set the long value of a field.
|
static void |
setObject(java.lang.Object instance,
java.lang.reflect.Field field,
java.lang.Object value)
Set the value of a field.
|
static void |
setShort(java.lang.Object instance,
java.lang.reflect.Field field,
short value)
Set the short value of a field.
|
public static long offset(java.lang.reflect.Field field)
field - The field to get the offset ofpublic static java.lang.Object instance(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The fieldpublic static java.lang.reflect.Field[] getDeclaredFields(java.lang.Class<?> clazz)
clazz - The class to get the fields fromMethodNotFoundException - If the Class internal getDeclaredFields0 method could not be found@Nullable
public static java.lang.reflect.Field getDeclaredField(java.lang.Class<?> clazz,
java.lang.String name)
clazz - The class to get the field ofname - The name of the fieldpublic static boolean getBoolean(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setBoolean(java.lang.Object instance,
java.lang.reflect.Field field,
boolean value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyBoolean(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static byte getByte(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setByte(java.lang.Object instance,
java.lang.reflect.Field field,
byte value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyByte(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static short getShort(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setShort(java.lang.Object instance,
java.lang.reflect.Field field,
short value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyShort(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static char getChar(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setChar(java.lang.Object instance,
java.lang.reflect.Field field,
char value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyChar(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static int getInt(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setInt(java.lang.Object instance,
java.lang.reflect.Field field,
int value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyInt(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static long getLong(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setLong(java.lang.Object instance,
java.lang.reflect.Field field,
long value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyLong(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static float getFloat(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setFloat(java.lang.Object instance,
java.lang.reflect.Field field,
float value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyFloat(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static double getDouble(java.lang.Object instance,
java.lang.reflect.Field field)
instance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setDouble(java.lang.Object instance,
java.lang.reflect.Field field,
double value)
instance - The instance or null if the field is staticfield - The field to get the value ofvalue - The value to setpublic static void copyDouble(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static <T> T getObject(java.lang.Object instance,
java.lang.reflect.Field field)
T - The type of the fieldinstance - The instance or null if the field is staticfield - The field to get the value ofpublic static void setObject(java.lang.Object instance,
java.lang.reflect.Field field,
java.lang.Object value)
instance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static void copyObject(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
instance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value ofpublic static <T> T get(java.lang.Object instance,
java.lang.reflect.Field field)
T - The type of the fieldinstance - The instance or null if the field is staticfield - The field to get the value ofpublic static <T> void set(java.lang.Object instance,
java.lang.reflect.Field field,
T value)
T - The type of the fieldinstance - The instance or null if the field is staticfield - The field to set the value ofvalue - The value to setpublic static <T> void copy(java.lang.Object instance,
java.lang.Object target,
java.lang.reflect.Field field)
T - The type of the fieldinstance - The instance to copy the value fromtarget - The instance to copy the value tofield - The field to copy the value of