Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/javax/lang/model/element/VariableElement.java
38899 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.lang.model.element;2627import javax.lang.model.util.Elements;2829/**30* Represents a field, {@code enum} constant, method or constructor31* parameter, local variable, resource variable, or exception32* parameter.33*34* @author Joseph D. Darcy35* @author Scott Seligman36* @author Peter von der Ahé37* @since 1.638*/39public interface VariableElement extends Element {4041/**42* Returns the value of this variable if this is a {@code final}43* field initialized to a compile-time constant. Returns {@code44* null} otherwise. The value will be of a primitive type or a45* {@code String}. If the value is of a primitive type, it is46* wrapped in the appropriate wrapper class (such as {@link47* Integer}).48*49* <p>Note that not all {@code final} fields will have50* constant values. In particular, {@code enum} constants are51* <em>not</em> considered to be compile-time constants. To have a52* constant value, a field's type must be either a primitive type53* or {@code String}.54*55* @return the value of this variable if this is a {@code final}56* field initialized to a compile-time constant, or {@code null}57* otherwise58*59* @see Elements#getConstantExpression(Object)60* @jls 15.28 Constant Expression61* @jls 4.12.4 final Variables62*/63Object getConstantValue();6465/**66* Returns the simple name of this variable element.67*68* <p>For method and constructor parameters, the name of each69* parameter must be distinct from the names of all other70* parameters of the same executable. If the original source71* names are not available, an implementation may synthesize names72* subject to the distinctness requirement above.73*74* @return the simple name of this variable element75*/76@Override77Name getSimpleName();7879/**80* Returns the enclosing element of this variable.81*82* The enclosing element of a method or constructor parameter is83* the executable declaring the parameter.84*85* @return the enclosing element of this variable86*/87@Override88Element getEnclosingElement();89}909192