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
- Author:
- Yaniv Inbar
-
Method Summary
Modifier and TypeMethodDescription<T extends Enum<T>>
TReturns the class information of the field's declaring class.getField()Returns the field.static ObjectgetFieldValue(Field field, Object obj) Returns the value of the given field in the given object 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.booleanisFinal()Returns whether the field is final.booleanReturns whether the field is primitive as defined byData.isPrimitive(Type).static FieldInfoReturns the field information for the given enum value.static FieldInfoReturns the field information for the given field.static voidsetFieldValue(Field field, Object obj, Object value) Sets the given field in the given object to the given value using reflection.voidSets this field in the given object to the given value using reflection.
-
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 ornullfornullresult- Returns:
- field information or
nullif the field has nonameor fornullinput
-
getField
Returns the field.- Since:
- 1.4
-
getName
Returns the data key name associated with the field for a non-enum-constant with aKeyannotation, or data key value associated with the enum constant with aValueannotation ornullfor an enum constant with aNullValueannotation.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 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.
-
getClassInfo
Returns the class information of the field's declaring class. -
enumValue
-
getFieldValue
Returns the value of the given field in the given object using reflection. -
setFieldValue
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.
-