public final class FieldAttributes
extends java.lang.Object
This class is immutable; therefore, it can be safely shared across threads.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.reflect.Field |
field |
| Constructor and Description |
|---|
FieldAttributes(java.lang.reflect.Field f)
Constructs a Field Attributes object from the
f. |
| Modifier and Type | Method and Description |
|---|---|
(package private) java.lang.Object |
get(java.lang.Object instance)
Returns the value of the field represented by this
Field, on
the specified object. |
<T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<T> annotation)
Return the
T annotation object from this field if it exist; otherwise returns
null. |
java.util.Collection<java.lang.annotation.Annotation> |
getAnnotations()
Return the annotations that are present on this field.
|
java.lang.Class<?> |
getDeclaredClass()
Returns the
Class object that was declared for this field. |
java.lang.reflect.Type |
getDeclaredType()
For example, assume the following class definition:
public class Foo {
private String bar;
private List<String> red;
}
Type listParameterizedType = new TypeToken<List<String>>() {}.getType(); |
java.lang.Class<?> |
getDeclaringClass() |
java.lang.String |
getName() |
boolean |
hasModifier(int modifier)
Returns
true if the field is defined with the modifier. |
(package private) boolean |
isSynthetic()
This is exposed internally only for the removing synthetic fields from the JSON output.
|
public FieldAttributes(java.lang.reflect.Field f)
f.f - the field to pull attributes frompublic java.lang.Class<?> getDeclaringClass()
public java.lang.String getName()
public java.lang.reflect.Type getDeclaredType()
For example, assume the following class definition:
public class Foo {
private String bar;
private List<String> red;
}
Type listParameterizedType = new TypeToken<List<String>>() {}.getType();
This method would return String.class for the bar field and
listParameterizedType for the red field.
public java.lang.Class<?> getDeclaredClass()
Class object that was declared for this field.
For example, assume the following class definition:
public class Foo {
private String bar;
private List<String> red;
}
This method would return String.class for the bar field and
List.class for the red field.
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annotation)
T annotation object from this field if it exist; otherwise returns
null.annotation - the class of the annotation that will be retrievednullpublic java.util.Collection<java.lang.annotation.Annotation> getAnnotations()
public boolean hasModifier(int modifier)
true if the field is defined with the modifier.
This method is meant to be called as:
boolean hasPublicModifier = fieldAttribute.hasModifier(java.lang.reflect.Modifier.PUBLIC);
Modifierjava.lang.Object get(java.lang.Object instance)
throws java.lang.IllegalAccessException
Field, on
the specified object. The value is automatically wrapped in an
object if it has a primitive type.obj; primitive values are wrapped in an appropriate
object before being returnedjava.lang.IllegalAccessExceptionjava.lang.IllegalArgumentExceptionboolean isSynthetic()