Class FieldInfo (1.44.2)

public class FieldInfo

Parses field information to determine data key name/value pair associated with the field.

Implementation is thread-safe.

Inheritance

Object > FieldInfo

Static Methods

getFieldValue(Field field, Object obj)

public static Object getFieldValue(Field field, Object obj)

Returns the value of the given field in the given object using reflection.

Parameters
Name Description
field Field
obj Object
Returns
Type Description
Object

of(Enum<?> enumValue)

public static FieldInfo of(Enum<?> enumValue)

Returns the field information for the given enum value.

Parameter
Name Description
enumValue Enum<?>

enum value

Returns
Type Description
FieldInfo

field information

of(Field field)

public static FieldInfo of(Field field)

Returns the field information for the given field.

Parameter
Name Description
field Field

field or null for null result

Returns
Type Description
FieldInfo

field information or null if the field has no #name or for null input

setFieldValue(Field field, Object obj, Object value)

public static void setFieldValue(Field field, Object obj, Object value)

Sets the given field in the given object to the given value using reflection.

If the field is final, it checks that the value being set is identical to the existing value.

Parameters
Name Description
field Field
obj Object
value Object

Methods

<T>enumValue()

public T <T>enumValue()
Returns
Type Description
T

getClassInfo()

public ClassInfo getClassInfo()

Returns the class information of the field's declaring class.

Returns
Type Description
ClassInfo

getField()

public Field getField()

Returns the field.

Returns
Type Description
Field

getGenericType()

public Type getGenericType()

Returns the field's generic type, which is a class, parameterized type, generic array type, or type variable, but not a wildcard type.

Returns
Type Description
Type

getName()

public String getName()

Returns the data key name associated with the field for a non-enum-constant with a Key annotation, or data key value associated with the enum constant with a Value annotation or null for an enum constant with a NullValue annotation.

This string is interned.

Returns
Type Description
String

getType()

public Class<?> getType()

Returns the field's type.

Returns
Type Description
Class<?>

getValue(Object obj)

public Object getValue(Object obj)

Returns the value of the field in the given object instance using reflection.

Parameter
Name Description
obj Object
Returns
Type Description
Object

isFinal()

public boolean isFinal()

Returns whether the field is final.

Returns
Type Description
boolean

isPrimitive()

public boolean isPrimitive()

Returns whether the field is primitive as defined by Data#isPrimitive(Type).

Returns
Type Description
boolean

setValue(Object obj, Object value)

public void setValue(Object obj, Object value)

Sets this field in the given object to the given value using reflection.

If the field is final, it checks that the value being set is identical to the existing value.

Parameters
Name Description
obj Object
value Object