langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java
author alanb
Fri, 10 Feb 2017 09:06:10 +0000
changeset 43767 9cff98a149cb
parent 36526 3b41f1c69604
permissions -rw-r--r--
8173393: Module system implementation refresh (2/2017) Reviewed-by: mcimadamore, mchung, alanb Contributed-by: alan.bateman@oracle.com, mandy.chung@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
     2
 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.lang.model.element;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * The {@code kind} of an element.
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * <p>Note that it is possible additional element kinds will be added
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * to accommodate new, currently unknown, language structures added to
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * future versions of the Java&trade; programming language.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @see Element
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
public enum ElementKind {
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    /** A package. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    PACKAGE,
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    // Declared types
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    /** An enum type. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    ENUM,
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /** A class not described by a more specific kind (like {@code ENUM}). */
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    CLASS,
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    /** An annotation type. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    ANNOTATION_TYPE,
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * An interface not described by a more specific kind (like
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * {@code ANNOTATION_TYPE}).
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    INTERFACE,
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    // Variables
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /** An enum constant. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    ENUM_CONSTANT,
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * A field not described by a more specific kind (like
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * {@code ENUM_CONSTANT}).
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    FIELD,
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    /** A parameter of a method or constructor. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    PARAMETER,
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /** A local variable. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    LOCAL_VARIABLE,
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    /** A parameter of an exception handler. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    EXCEPTION_PARAMETER,
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    // Executables
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    /** A method. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    METHOD,
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    /** A constructor. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    CONSTRUCTOR,
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    /** A static initializer. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    STATIC_INIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /** An instance initializer. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    INSTANCE_INIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    /** A type parameter. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    TYPE_PARAMETER,
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * An implementation-reserved element.  This is not the element
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * you are looking for.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     */
6028
c8a98b3e9f79 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents: 5520
diff changeset
    91
    OTHER,
c8a98b3e9f79 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents: 5520
diff changeset
    92
c8a98b3e9f79 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents: 5520
diff changeset
    93
    /**
c8a98b3e9f79 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents: 5520
diff changeset
    94
     * A resource variable.
c8a98b3e9f79 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents: 5520
diff changeset
    95
     * @since 1.7
c8a98b3e9f79 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents: 5520
diff changeset
    96
     */
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    97
     RESOURCE_VARIABLE,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    98
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    99
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   100
     * A module.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   101
     * @since 9
43767
9cff98a149cb 8173393: Module system implementation refresh (2/2017)
alanb
parents: 36526
diff changeset
   102
     * @spec JPMS
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   103
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   104
     MODULE;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * Returns {@code true} if this is a kind of class:
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * either {@code CLASS} or {@code ENUM}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * @return {@code true} if this is a kind of class
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    public boolean isClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        return this == CLASS || this == ENUM;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * Returns {@code true} if this is a kind of interface:
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * @return {@code true} if this is a kind of interface
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    public boolean isInterface() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        return this == INTERFACE || this == ANNOTATION_TYPE;
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * Returns {@code true} if this is a kind of field:
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * either {@code FIELD} or {@code ENUM_CONSTANT}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * @return {@code true} if this is a kind of field
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    public boolean isField() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        return this == FIELD || this == ENUM_CONSTANT;
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
}