AnnotatedConstruct
, Element
public interface VariableElement extends Element
enum
constant, method or constructor parameter, local variable, resource variable, or exception parameter.Modifier and Type | Method | Description |
---|---|---|
TypeMirror |
asType() |
Returns the type of this variable. |
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. |
default boolean |
isUnnamed() |
Preview. Returns true if this is an unnamed variable and
false otherwise. |
accept, equals, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getEnclosedElements, getKind, getModifiers, hashCode
TypeMirror asType()
Object 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
otherwiseName 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.
For variables, the name of each variable is returned, or an empty name if the variable is unnamed.
getSimpleName
in interface Element
Element getEnclosingElement()
getEnclosingElement
in interface Element
default boolean isUnnamed()
isUnnamed
is a reflective preview API of the Java platform. true
if this is an unnamed variable and
false
otherwise.
getSimpleName()
and returns true
if the result is empty and false
otherwise.true
if this is an unnamed variable and
false
otherwise
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.compiler/javax/lang/model/element/VariableElement.html