1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   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 /**
  29  * The {@code kind} of an element.
  30  *
  31  * <p>Note that it is possible additional element kinds will be added
  32  * to accommodate new, currently unknown, language structures added to
  33  * future versions of the Java&trade; programming language.
  34  *
  35  * @author Joseph D. Darcy
  36  * @author Scott Seligman
  37  * @author Peter von der Ah&eacute;
  38  * @see Element
  39  * @since 1.6
  40  */
  41 public enum ElementKind {
  42 
  43     /** A package. */
  44     PACKAGE,
  45 
  46     // Declared types
  47     /** An enum type. */
  48     ENUM,
  49     /**
  50      * A class not described by a more specific kind (like {@code
  51      * ENUM} or {@code RECORD}).
  52      */
  53     CLASS,
  54     /**
  55      * A record type.
  56      * @since 13
  57      */
  58     RECORD,
  59     /** An annotation type. */
  60     ANNOTATION_TYPE,
  61     /**
  62      * An interface not described by a more specific kind (like
  63      * {@code ANNOTATION_TYPE}).
  64      */
  65     INTERFACE,
  66 
  67     // Neither fish nor fowl; necessary?
  68     /**
  69      * A state description of a {@code record}.
  70      * @since 13
  71      */
  72      STATE_DESCRIPTION,
  73 
  74     // Variables
  75     /** An enum constant. */
  76     ENUM_CONSTANT,
  77     /**
  78      * A field not described by a more specific kind (like
  79      * {@code ENUM_CONSTANT}).
  80      */
  81     FIELD,
  82     /** A parameter of a method or constructor. */
  83     PARAMETER,
  84     /** A local variable. */
  85     LOCAL_VARIABLE,
  86     /** A parameter of an exception handler. */
  87     EXCEPTION_PARAMETER,
  88 
  89     // Executables
  90     /** A method. */
  91     METHOD,
  92     /** A constructor. */
  93     CONSTRUCTOR,
  94     /** A static initializer. */
  95     STATIC_INIT,
  96     /** An instance initializer. */
  97     INSTANCE_INIT,
  98 
  99     /** A type parameter. */
 100     TYPE_PARAMETER,
 101 
 102     /**
 103      * An implementation-reserved element.  This is not the element
 104      * you are looking for.
 105      */
 106     OTHER,
 107 
 108     /**
 109      * A resource variable.
 110      * @since 1.7
 111      */
 112      RESOURCE_VARIABLE,
 113 
 114     /**
 115      * A module.
 116      * @since 9
 117      * @spec JPMS
 118      */
 119      MODULE;
 120 
 121 
 122     /**
 123      * Returns {@code true} if this is a kind of class:
 124      * either {@code CLASS} or {@code ENUM} or {@code RECORD}.
 125      *
 126      * @return {@code true} if this is a kind of class
 127      */
 128     public boolean isClass() {
 129         return this == CLASS || this == ENUM || this == RECORD;
 130     }
 131 
 132     /**
 133      * Returns {@code true} if this is a kind of interface:
 134      * either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
 135      *
 136      * @return {@code true} if this is a kind of interface
 137      */
 138     public boolean isInterface() {
 139         return this == INTERFACE || this == ANNOTATION_TYPE;
 140     }
 141 
 142     /**
 143      * Returns {@code true} if this is a kind of field:
 144      * either {@code FIELD} or {@code ENUM_CONSTANT}.
 145      *
 146      * @return {@code true} if this is a kind of field
 147      */
 148     public boolean isField() {
 149         return this == FIELD || this == ENUM_CONSTANT;
 150     }
 151 }