001: /*
002: * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package javax.lang.model.element;
027:
028: /**
029: * The {@code kind} of an element.
030: *
031: * <p>Note that it is possible additional element kinds will be added
032: * to accommodate new, currently unknown, language structures added to
033: * future versions of the Java™ programming language.
034: *
035: * @author Joseph D. Darcy
036: * @author Scott Seligman
037: * @author Peter von der Ahé
038: * @version 1.10 07/05/05
039: * @see Element
040: * @since 1.6
041: */
042: public enum ElementKind {
043:
044: /** A package. */
045: PACKAGE,
046:
047: // Declared types
048: /** An enum type. */
049: ENUM,
050: /** A class not described by a more specific kind (like {@code ENUM}). */
051: CLASS,
052: /** An annotation type. */
053: ANNOTATION_TYPE,
054: /**
055: * An interface not described by a more specific kind (like
056: * {@code ANNOTATION_TYPE}).
057: */
058: INTERFACE,
059:
060: // Variables
061: /** An enum constant. */
062: ENUM_CONSTANT,
063: /**
064: * A field not described by a more specific kind (like
065: * {@code ENUM_CONSTANT}).
066: */
067: FIELD,
068: /** A parameter of a method or constructor. */
069: PARAMETER,
070: /** A local variable. */
071: LOCAL_VARIABLE,
072: /** A parameter of an exception handler. */
073: EXCEPTION_PARAMETER,
074:
075: // Executables
076: /** A method. */
077: METHOD,
078: /** A constructor. */
079: CONSTRUCTOR,
080: /** A static initializer. */
081: STATIC_INIT,
082: /** An instance initializer. */
083: INSTANCE_INIT,
084:
085: /** A type parameter. */
086: TYPE_PARAMETER,
087:
088: /**
089: * An implementation-reserved element. This is not the element
090: * you are looking for.
091: */
092: OTHER;
093:
094: /**
095: * Returns {@code true} if this is a kind of class:
096: * either {@code CLASS} or {@code ENUM}.
097: *
098: * @return {@code true} if this is a kind of class
099: */
100: public boolean isClass() {
101: return this == CLASS || this == ENUM;
102: }
103:
104: /**
105: * Returns {@code true} if this is a kind of interface:
106: * either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
107: *
108: * @return {@code true} if this is a kind of interface
109: */
110: public boolean isInterface() {
111: return this == INTERFACE || this == ANNOTATION_TYPE;
112: }
113:
114: /**
115: * Returns {@code true} if this is a kind of field:
116: * either {@code FIELD} or {@code ENUM_CONSTANT}.
117: *
118: * @return {@code true} if this is a kind of field
119: */
120: public boolean isField() {
121: return this == FIELD || this == ENUM_CONSTANT;
122: }
123: }
|