public class FieldInfo extends Object
Implementation is thread-safe.
Modifier and Type | Method and Description |
---|---|
<T extends Enum<T>> |
enumValue() |
ClassInfo |
getClassInfo()
Returns the class information of the field's declaring class.
|
Field |
getField()
Returns the field.
|
static Object |
getFieldValue(Field field,
Object obj)
Returns the value of the given field in the given object using reflection.
|
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.
|
String |
getName()
|
Class<?> |
getType()
Returns the field's type.
|
Object |
getValue(Object obj)
Returns the value of the field in the given object instance using reflection.
|
boolean |
isFinal()
Returns whether the field is final.
|
boolean |
isPrimitive()
Returns whether the field is primitive as defined by
Data.isPrimitive(Type) . |
static FieldInfo |
of(Enum<?> enumValue)
Returns the field information for the given enum value.
|
static FieldInfo |
of(Field field)
Returns the field information for the given field.
|
static void |
setFieldValue(Field field,
Object obj,
Object value)
Sets the given field in the given object to the given value using reflection.
|
void |
setValue(Object obj,
Object value)
Sets this field in the given object to the given value using reflection.
|
public static FieldInfo of(Enum<?> enumValue)
enumValue
- enum valueIllegalArgumentException
- if the enum value has no value annotationpublic static FieldInfo of(Field field)
field
- field or null
for null
resultnull
if the field has no name
or for null
inputpublic Field getField()
public String getName()
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.
public Class<?> getType()
public Type getGenericType()
public boolean isFinal()
public boolean isPrimitive()
Data.isPrimitive(Type)
.public Object getValue(Object obj)
public void setValue(Object obj, Object value)
If the field is final, it checks that the value being set is identical to the existing value.
public ClassInfo getClassInfo()
public <T extends Enum<T>> T enumValue()
public static Object getFieldValue(Field field, Object obj)
Copyright © 2011–2024 Google. All rights reserved.