# Class FieldInfo (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.FieldInfo)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.util.FieldInfo)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.util.FieldInfo)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.util.FieldInfo)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.util.FieldInfo)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.util.FieldInfo)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.util.FieldInfo)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.util.FieldInfo)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.util.FieldInfo)

    public class FieldInfo

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

Implementation is thread-safe.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> FieldInfo

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html` |
| `obj` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |   |

### of(Enum\<?\> enumValue)

    public static FieldInfo of(Enum<?> enumValue)

Returns the field information for the given enum value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `enumValue` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html<?>` enum value |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.FieldInfo` | field information |

### of(Field field)

    public static FieldInfo of(Field field)

Returns the field information for the given field.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `field` | `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html` field or `null` for `null` result |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html` |
| `obj` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

## 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** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.ClassInfo` |   |

### getField()

    public Field getField()

Returns the field.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html` |   |

### 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** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html` |   |

### getName()

    public String getName()

Returns the data key name associated with the field for a non-enum-constant with a [Key](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Key)
annotation, or data key value associated with the enum constant with a [Value](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Value) annotation
or `null` for an enum constant with a [NullValue](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.NullValue) annotation.

This string is interned.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getType()

    public Class<?> getType()

Returns the field's type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<?>` |   |

### 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |   |

### isFinal()

    public boolean isFinal()

Returns whether the field is final.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### isPrimitive()

    public boolean isPrimitive()

Returns whether the field is primitive as defined by [Data#isPrimitive(Type)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Data#com_google_api_client_util_Data_isPrimitive_java_lang_reflect_Type_).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |