public class FieldAttributes extends Object implements MemberAttributes<Field>
| 构造器和说明 |
|---|
FieldAttributes(Field f)
Constructs a Field Attributes object from the
f. |
| 限定符和类型 | 方法和说明 |
|---|---|
Field |
get() |
<T extends Annotation> |
getAnnotation(Class<T> annotation)
Return the
T annotation object from this field if it exist; otherwise returns
null. |
Collection<Annotation> |
getAnnotations()
Return the annotations that are present on this field.
|
Class<?> |
getDeclaredClass()
Returns the
Class object that was declared for this field. |
Type |
getDeclaredType()
已过时。
|
Class<?> |
getDeclaringClass() |
int |
getModifier() |
String |
getName() |
boolean |
hasModifier(int modifier)
Returns
true if the field is defined with the modifier. |
public FieldAttributes(Field f)
f.f - the field to pull attributes frompublic int getModifier()
getModifier 在接口中 MemberAttributes<Field>public Field get()
get 在接口中 MemberAttributes<Field>public Class<?> getDeclaringClass()
getDeclaringClass 在接口中 MemberAttributes<Field>public String getName()
getName 在接口中 MemberAttributes<Field>@Deprecated public 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 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 Annotation> T getAnnotation(Class<T> annotation)
T annotation object from this field if it exist; otherwise returns
null.getAnnotation 在接口中 MemberAttributes<Field>annotation - the class of the annotation that will be retrievednullpublic Collection<Annotation> getAnnotations()
getAnnotations 在接口中 MemberAttributes<Field>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);
hasModifier 在接口中 MemberAttributes<Field>ModifierCopyright © 2020. All rights reserved.