01: /*
02: * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package javax.lang.model.element;
27:
28: import javax.lang.model.type.TypeMirror;
29: import javax.lang.model.util.Elements;
30:
31: /**
32: * Represents a field, {@code enum} constant, method or constructor
33: * parameter, local variable, or exception parameter.
34: *
35: * @author Joseph D. Darcy
36: * @author Scott Seligman
37: * @author Peter von der Ahé
38: * @version 1.10 07/05/05
39: * @since 1.6
40: */
41:
42: public interface VariableElement extends Element {
43:
44: /**
45: * Returns the value of this variable if this is a {@code final}
46: * field initialized to a compile-time constant. Returns {@code
47: * null} otherwise. The value will be of a primitive type or a
48: * {@code String}. If the value is of a primitive type, it is
49: * wrapped in the appropriate wrapper class (such as {@link
50: * Integer}).
51: *
52: * <p>Note that not all {@code final} fields will have
53: * constant values. In particular, {@code enum} constants are
54: * <em>not</em> considered to be compile-time constants. To have a
55: * constant value, a field's type must be either a primitive type
56: * or {@code String}.
57: *
58: * @return the value of this variable if this is a {@code final}
59: * field initialized to a compile-time constant, or {@code null}
60: * otherwise
61: *
62: * @see Elements#getConstantExpression(Object)
63: * @jls3 15.28 Constant Expression
64: * @jls3 4.12.4 final Variables
65: */
66: Object getConstantValue();
67: }
|