Package com.google.api.client.util
Class FieldInfo
java.lang.Object
com.google.api.client.util.FieldInfo
Parses field information to determine data key name/value pair associated with the field.
Implementation is thread-safe.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionCached field information.private final Field
Field.private final boolean
Whether the field class is "primitive" as defined byData.isPrimitive(Type)
.private final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends Enum<T>>
TReturns the class information of the field's declaring class.getField()
Returns the field.static Object
getFieldValue
(Field field, Object obj) Returns the value of the given field in the given object instance using reflection.Returns the field's generic type, which is a class, parameterized type, generic array type, or type variable, but not a wildcard type.getName()
Class
<?> getType()
Returns the field's type.Returns the value of the field in the given object instance using reflection.boolean
isFinal()
Returns whether the field is final.boolean
Returns whether the field is primitive as defined byData.isPrimitive(Type)
.static FieldInfo
Returns the field information for the given enum value.static FieldInfo
Returns the field information for the given field.static void
setFieldValue
(Field field, Object obj, Object value) Sets to the given value of the given field in the given object instance using reflection.void
Sets to the given value of the field in the given object instance using reflection.
-
Field Details
-
CACHE
Cached field information. -
isPrimitive
private final boolean isPrimitiveWhether the field class is "primitive" as defined byData.isPrimitive(Type)
. -
field
Field. -
name
-
-
Constructor Details
-
FieldInfo
-
-
Method Details
-
of
Returns the field information for the given enum value.- Parameters:
enumValue
- enum value- Returns:
- field information
- Throws:
IllegalArgumentException
- if the enum value has no value annotation- Since:
- 1.4
-
of
Returns the field information for the given field.- Parameters:
field
- field ornull
fornull
result- Returns:
- field information or
null
if the field has noname
or fornull
input
-
getField
Returns the field.- Since:
- 1.4
-
getName
Returns the data key name associated with the field for a non-enum-constant with aKey
annotation, or data key value associated with the enum constant with aValue
annotation ornull
for an enum constant with aNullValue
annotation.This string is interned.
- Since:
- 1.4
-
getType
Returns the field's type.- Since:
- 1.4
-
getGenericType
Returns the field's generic type, which is a class, parameterized type, generic array type, or type variable, but not a wildcard type.- Since:
- 1.4
-
isFinal
public boolean isFinal()Returns whether the field is final.- Since:
- 1.4
-
isPrimitive
public boolean isPrimitive()Returns whether the field is primitive as defined byData.isPrimitive(Type)
.- Since:
- 1.4
-
getValue
Returns the value of the field in the given object instance using reflection. -
setValue
Sets to the given value of the field in the given object instance using reflection.If the field is final, it checks that value being set is identical to the existing value.
-
getClassInfo
Returns the class information of the field's declaring class. -
enumValue
-
getFieldValue
Returns the value of the given field in the given object instance using reflection. -
setFieldValue
Sets to the given value of the given field in the given object instance using reflection.If the field is final, it checks that value being set is identical to the existing value.
-