< prev index next >

src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java

Print this page




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.lang.model.element;
  27 
  28 import javax.lang.model.util.Elements;

  29 
  30 /**
  31  * Represents a field, {@code enum} constant, method or constructor
  32  * parameter, local variable, resource variable, or exception
  33  * parameter.
  34  *
  35  * @author Joseph D. Darcy
  36  * @author Scott Seligman
  37  * @author Peter von der Ah&eacute;
  38  * @since 1.6
  39  */
  40 public interface VariableElement extends Element {






  41 
  42     /**
  43      * Returns the value of this variable if this is a {@code final}
  44      * field initialized to a compile-time constant.  Returns {@code
  45      * null} otherwise.  The value will be of a primitive type or a
  46      * {@code String}.  If the value is of a primitive type, it is
  47      * wrapped in the appropriate wrapper class (such as {@link
  48      * Integer}).
  49      *
  50      * <p>Note that not all {@code final} fields will have
  51      * constant values.  In particular, {@code enum} constants are
  52      * <em>not</em> considered to be compile-time constants.  To have a
  53      * constant value, a field's type must be either a primitive type
  54      * or {@code String}.
  55      *
  56      * @return the value of this variable if this is a {@code final}
  57      * field initialized to a compile-time constant, or {@code null}
  58      * otherwise
  59      *
  60      * @see Elements#getConstantExpression(Object)




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.lang.model.element;
  27 
  28 import javax.lang.model.util.Elements;
  29 import javax.lang.model.type.TypeMirror;
  30 
  31 /**
  32  * Represents a field, {@code enum} constant, method or constructor
  33  * parameter, local variable, resource variable, or exception
  34  * parameter.
  35  *
  36  * @author Joseph D. Darcy
  37  * @author Scott Seligman
  38  * @author Peter von der Ah&eacute;
  39  * @since 1.6
  40  */
  41 public interface VariableElement extends Element {
  42     /**
  43      * Returns the type of this variable.
  44      * @return the type of this variable
  45      */
  46     @Override
  47     TypeMirror asType();
  48 
  49     /**
  50      * Returns the value of this variable if this is a {@code final}
  51      * field initialized to a compile-time constant.  Returns {@code
  52      * null} otherwise.  The value will be of a primitive type or a
  53      * {@code String}.  If the value is of a primitive type, it is
  54      * wrapped in the appropriate wrapper class (such as {@link
  55      * Integer}).
  56      *
  57      * <p>Note that not all {@code final} fields will have
  58      * constant values.  In particular, {@code enum} constants are
  59      * <em>not</em> considered to be compile-time constants.  To have a
  60      * constant value, a field's type must be either a primitive type
  61      * or {@code String}.
  62      *
  63      * @return the value of this variable if this is a {@code final}
  64      * field initialized to a compile-time constant, or {@code null}
  65      * otherwise
  66      *
  67      * @see Elements#getConstantExpression(Object)


< prev index next >