AnnotatedConstruct, Elementpublic interface VariableElement extends Element
enum constant, method or constructor
parameter, local variable, resource variable, or exception
parameter.| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Object |
getConstantValue() |
Returns the value of this variable if this is a
final
field initialized to a compile-time constant. |
Element |
getEnclosingElement() |
Returns the enclosing element of this variable.
|
Name |
getSimpleName() |
Returns the simple name of this variable element.
|
getAnnotationsByTypeaccept, asType, equals, getAnnotation, getAnnotationMirrors, getEnclosedElements, getKind, getModifiers, hashCodeObject getConstantValue()
final
field initialized to a compile-time constant. Returns
null otherwise. The value will be of a primitive type or a
String. If the value is of a primitive type, it is
wrapped in the appropriate wrapper class (such as Integer).
Note that not all final fields will have
constant values. In particular, enum constants are
not considered to be compile-time constants. To have a
constant value, a field's type must be either a primitive type
or String.
final
field initialized to a compile-time constant, or null
otherwiseElements.getConstantExpression(Object)Name getSimpleName()
For method and constructor parameters, the name of each parameter must be distinct from the names of all other parameters of the same executable. If the original source names are not available, an implementation may synthesize names subject to the distinctness requirement above.
getSimpleName 在接口中 ElementPackageElement.getSimpleName(),
ExecutableElement.getSimpleName(),
TypeElement.getSimpleName(),
getSimpleName()Element getEnclosingElement()
getEnclosingElement 在接口中 ElementElements.getPackageOf(javax.lang.model.element.Element)