Package com.badlogic.gdx.utils.reflect
Class Field
- java.lang.Object
-
- com.badlogic.gdx.utils.reflect.Field
-
public final class Field extends java.lang.ObjectProvides information about, and access to, a single field of a class or interface.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectget(java.lang.Object obj)Returns the value of the field on the supplied object.AnnotationgetDeclaredAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Returns anAnnotationobject reflecting the annotation provided, or null of this field doesn't have such an annotation.Annotation[]getDeclaredAnnotations()Returns an array ofAnnotationobjects reflecting all annotations declared by this field, or an empty array if there are none.java.lang.ClassgetDeclaringClass()Returns the Class object representing the class or interface that declares the field.java.lang.ClassgetElementType(int index)If the type of the field is parameterized, returns the Class object representing the parameter type at the specified index, null otherwise.java.lang.StringgetName()Returns the name of the field.java.lang.ClassgetType()Returns a Class object that identifies the declared type for the field.booleanisAccessible()booleanisAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Returns true if the field includes an annotation of the provided class type.booleanisDefaultAccess()Return true if the field does not include any of theprivate,protected, orpublicmodifiers.booleanisFinal()Return true if the field includes thefinalmodifier.booleanisPrivate()Return true if the field includes theprivatemodifier.booleanisProtected()Return true if the field includes theprotectedmodifier.booleanisPublic()Return true if the field includes thepublicmodifier.booleanisStatic()Return true if the field includes thestaticmodifier.booleanisSynthetic()Return true if the field is a synthetic field.booleanisTransient()Return true if the field includes thetransientmodifier.booleanisVolatile()Return true if the field includes thevolatilemodifier.voidset(java.lang.Object obj, java.lang.Object value)Sets the value of the field on the supplied object.voidsetAccessible(boolean accessible)
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of the field.
-
getType
public java.lang.Class getType()
Returns a Class object that identifies the declared type for the field.
-
getDeclaringClass
public java.lang.Class getDeclaringClass()
Returns the Class object representing the class or interface that declares the field.
-
isAccessible
public boolean isAccessible()
-
setAccessible
public void setAccessible(boolean accessible)
-
isDefaultAccess
public boolean isDefaultAccess()
Return true if the field does not include any of theprivate,protected, orpublicmodifiers.
-
isFinal
public boolean isFinal()
Return true if the field includes thefinalmodifier.
-
isPrivate
public boolean isPrivate()
Return true if the field includes theprivatemodifier.
-
isProtected
public boolean isProtected()
Return true if the field includes theprotectedmodifier.
-
isPublic
public boolean isPublic()
Return true if the field includes thepublicmodifier.
-
isStatic
public boolean isStatic()
Return true if the field includes thestaticmodifier.
-
isTransient
public boolean isTransient()
Return true if the field includes thetransientmodifier.
-
isVolatile
public boolean isVolatile()
Return true if the field includes thevolatilemodifier.
-
isSynthetic
public boolean isSynthetic()
Return true if the field is a synthetic field.
-
getElementType
public java.lang.Class getElementType(int index)
If the type of the field is parameterized, returns the Class object representing the parameter type at the specified index, null otherwise.
-
isAnnotationPresent
public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns true if the field includes an annotation of the provided class type.
-
getDeclaredAnnotations
public Annotation[] getDeclaredAnnotations()
Returns an array ofAnnotationobjects reflecting all annotations declared by this field, or an empty array if there are none. Does not include inherited annotations.
-
getDeclaredAnnotation
public Annotation getDeclaredAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns anAnnotationobject reflecting the annotation provided, or null of this field doesn't have such an annotation. This is a convenience function if the caller knows already which annotation type he's looking for.
-
get
public java.lang.Object get(java.lang.Object obj) throws ReflectionExceptionReturns the value of the field on the supplied object.- Throws:
ReflectionException
-
set
public void set(java.lang.Object obj, java.lang.Object value) throws ReflectionExceptionSets the value of the field on the supplied object.- Throws:
ReflectionException
-
-