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&trade; programming language.
034     *
035     * @author Joseph D. Darcy
036     * @author Scott Seligman
037     * @author Peter von der Ah&eacute;
038     * @see Element
039     * @since 1.6
040     */
041    public enum ElementKind {
042    
043        /** A package. */
044        PACKAGE,
045    
046        // Declared types
047        /** An enum type. */
048        ENUM,
049        /** A class not described by a more specific kind (like {@code ENUM}). */
050        CLASS,
051        /** An annotation type. */
052        ANNOTATION_TYPE,
053        /**
054         * An interface not described by a more specific kind (like
055         * {@code ANNOTATION_TYPE}).
056         */
057        INTERFACE,
058    
059        // Variables
060        /** An enum constant. */
061        ENUM_CONSTANT,
062        /**
063         * A field not described by a more specific kind (like
064         * {@code ENUM_CONSTANT}).
065         */
066        FIELD,
067        /** A parameter of a method or constructor. */
068        PARAMETER,
069        /** A local variable. */
070        LOCAL_VARIABLE,
071        /** A parameter of an exception handler. */
072        EXCEPTION_PARAMETER,
073    
074        // Executables
075        /** A method. */
076        METHOD,
077        /** A constructor. */
078        CONSTRUCTOR,
079        /** A static initializer. */
080        STATIC_INIT,
081        /** An instance initializer. */
082        INSTANCE_INIT,
083    
084        /** A type parameter. */
085        TYPE_PARAMETER,
086    
087        /**
088         * An implementation-reserved element.  This is not the element
089         * you are looking for.
090         */
091        OTHER;
092    
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    }