public final class Field
extends java.lang.Object
限定符和类型 | 方法和说明 |
---|---|
java.lang.Object |
get(java.lang.Object obj)
Returns the value of the field on the supplied object.
|
Annotation |
getDeclaredAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns an
Annotation object reflecting the annotation provided, or null of this field doesn't
have such an annotation. |
Annotation[] |
getDeclaredAnnotations()
Returns an array of
Annotation objects reflecting all annotations declared by this field,
or an empty array if there are none. |
java.lang.Class |
getDeclaringClass()
Returns the Class object representing the class or interface that declares the field.
|
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.
|
java.lang.String |
getName()
Returns the name of the field.
|
java.lang.Class |
getType()
Returns a Class object that identifies the declared type for the field.
|
boolean |
isAccessible() |
boolean |
isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns true if the field includes an annotation of the provided class type.
|
boolean |
isDefaultAccess()
Return true if the field does not include any of the
private , protected , or public modifiers. |
boolean |
isFinal()
Return true if the field includes the
final modifier. |
boolean |
isPrivate()
Return true if the field includes the
private modifier. |
boolean |
isProtected()
Return true if the field includes the
protected modifier. |
boolean |
isPublic()
Return true if the field includes the
public modifier. |
boolean |
isStatic()
Return true if the field includes the
static modifier. |
boolean |
isSynthetic()
Return true if the field is a synthetic field.
|
boolean |
isTransient()
Return true if the field includes the
transient modifier. |
boolean |
isVolatile()
Return true if the field includes the
volatile modifier. |
void |
set(java.lang.Object obj,
java.lang.Object value)
Sets the value of the field on the supplied object.
|
void |
setAccessible(boolean accessible) |
public java.lang.String getName()
public java.lang.Class getType()
public java.lang.Class getDeclaringClass()
public boolean isAccessible()
public void setAccessible(boolean accessible)
public boolean isDefaultAccess()
private
, protected
, or public
modifiers.public boolean isFinal()
final
modifier.public boolean isPrivate()
private
modifier.public boolean isProtected()
protected
modifier.public boolean isPublic()
public
modifier.public boolean isStatic()
static
modifier.public boolean isTransient()
transient
modifier.public boolean isVolatile()
volatile
modifier.public boolean isSynthetic()
public java.lang.Class getElementType(int index)
public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public Annotation[] getDeclaredAnnotations()
Annotation
objects reflecting all annotations declared by this field,
or an empty array if there are none. Does not include inherited annotations.public Annotation getDeclaredAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Annotation
object 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.public java.lang.Object get(java.lang.Object obj) throws ReflectionException
public void set(java.lang.Object obj, java.lang.Object value) throws ReflectionException