Path: blob/master/src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java
41161 views
/*1* Copyright (c) 2005, 2020, 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 class. */47ENUM,48/**49* A class not described by a more specific kind (like {@code50* ENUM} or {@code RECORD}).51*/52CLASS,5354/** An annotation interface. (Formerly known as an annotation type.) */55ANNOTATION_TYPE,56/**57* An interface not described by a more specific kind (like58* {@code ANNOTATION_TYPE}).59*/60INTERFACE,6162// Variables63/** An enum constant. */64ENUM_CONSTANT,65/**66* A field not described by a more specific kind (like67* {@code ENUM_CONSTANT}).68*/69FIELD,70/** A parameter of a method or constructor. */71PARAMETER,72/** A local variable. */73LOCAL_VARIABLE,74/** A parameter of an exception handler. */75EXCEPTION_PARAMETER,7677// Executables78/** A method. */79METHOD,80/** A constructor. */81CONSTRUCTOR,82/** A static initializer. */83STATIC_INIT,84/** An instance initializer. */85INSTANCE_INIT,8687/** A type parameter. */88TYPE_PARAMETER,8990/**91* An implementation-reserved element. This is not the element92* you are looking for.93*/94OTHER,9596// Constants added since initial release9798/**99* A resource variable.100* @since 1.7101*/102RESOURCE_VARIABLE,103104/**105* A module.106* @since 9107*/108MODULE,109110/**111* A record class.112* @since 16113*/114RECORD,115116/**117* A record component of a {@code record}.118* @since 16119*/120RECORD_COMPONENT,121122/**123* A binding variable in a pattern.124* @since 16125*/126BINDING_VARIABLE;127128/**129* Returns {@code true} if this is a kind of class:130* either {@code CLASS} or {@code ENUM} or {@code RECORD}.131*132* @return {@code true} if this is a kind of class133*/134@SuppressWarnings("preview")135public boolean isClass() {136return this == CLASS || this == ENUM || this == RECORD;137}138139/**140* Returns {@code true} if this is a kind of interface:141* either {@code INTERFACE} or {@code ANNOTATION_TYPE}.142*143* @return {@code true} if this is a kind of interface144*/145public boolean isInterface() {146return this == INTERFACE || this == ANNOTATION_TYPE;147}148149/**150* Returns {@code true} if this is a kind of field:151* either {@code FIELD} or {@code ENUM_CONSTANT}.152*153* @return {@code true} if this is a kind of field154*/155public boolean isField() {156return this == FIELD || this == ENUM_CONSTANT;157}158}159160161