Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/javax/lang/model/element/ElementKind.java
38899 views
/*1* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.lang.model.element;2627/**28* The {@code kind} of an element.29*30* <p>Note that it is possible additional element kinds will be added31* to accommodate new, currently unknown, language structures added to32* future versions of the Java™ programming language.33*34* @author Joseph D. Darcy35* @author Scott Seligman36* @author Peter von der Ahé37* @see Element38* @since 1.639*/40public enum ElementKind {4142/** A package. */43PACKAGE,4445// Declared types46/** An enum type. */47ENUM,48/** A class not described by a more specific kind (like {@code ENUM}). */49CLASS,50/** An annotation type. */51ANNOTATION_TYPE,52/**53* An interface not described by a more specific kind (like54* {@code ANNOTATION_TYPE}).55*/56INTERFACE,5758// Variables59/** An enum constant. */60ENUM_CONSTANT,61/**62* A field not described by a more specific kind (like63* {@code ENUM_CONSTANT}).64*/65FIELD,66/** A parameter of a method or constructor. */67PARAMETER,68/** A local variable. */69LOCAL_VARIABLE,70/** A parameter of an exception handler. */71EXCEPTION_PARAMETER,7273// Executables74/** A method. */75METHOD,76/** A constructor. */77CONSTRUCTOR,78/** A static initializer. */79STATIC_INIT,80/** An instance initializer. */81INSTANCE_INIT,8283/** A type parameter. */84TYPE_PARAMETER,8586/**87* An implementation-reserved element. This is not the element88* you are looking for.89*/90OTHER,9192/**93* A resource variable.94* @since 1.795*/96RESOURCE_VARIABLE;979899/**100* Returns {@code true} if this is a kind of class:101* either {@code CLASS} or {@code ENUM}.102*103* @return {@code true} if this is a kind of class104*/105public boolean isClass() {106return this == CLASS || this == ENUM;107}108109/**110* Returns {@code true} if this is a kind of interface:111* either {@code INTERFACE} or {@code ANNOTATION_TYPE}.112*113* @return {@code true} if this is a kind of interface114*/115public boolean isInterface() {116return this == INTERFACE || this == ANNOTATION_TYPE;117}118119/**120* Returns {@code true} if this is a kind of field:121* either {@code FIELD} or {@code ENUM_CONSTANT}.122*123* @return {@code true} if this is a kind of field124*/125public boolean isField() {126return this == FIELD || this == ENUM_CONSTANT;127}128}129130131