1 | /* |
2 | * Copyright 2005-2006 Sun Microsystems, Inc. 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. Sun designates this |
8 | * particular file as subject to the "Classpath" exception as provided |
9 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
23 | * have any 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™ programming language. |
34 | * |
35 | * @author Joseph D. Darcy |
36 | * @author Scott Seligman |
37 | * @author Peter von der Ahé |
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 | /** A class not described by a more specific kind (like {@code ENUM}). */ |
50 | CLASS, |
51 | /** An annotation type. */ |
52 | ANNOTATION_TYPE, |
53 | /** |
54 | * An interface not described by a more specific kind (like |
55 | * {@code ANNOTATION_TYPE}). |
56 | */ |
57 | INTERFACE, |
58 | |
59 | // Variables |
60 | /** An enum constant. */ |
61 | ENUM_CONSTANT, |
62 | /** |
63 | * A field not described by a more specific kind (like |
64 | * {@code ENUM_CONSTANT}). |
65 | */ |
66 | FIELD, |
67 | /** A parameter of a method or constructor. */ |
68 | PARAMETER, |
69 | /** A local variable. */ |
70 | LOCAL_VARIABLE, |
71 | /** A parameter of an exception handler. */ |
72 | EXCEPTION_PARAMETER, |
73 | |
74 | // Executables |
75 | /** A method. */ |
76 | METHOD, |
77 | /** A constructor. */ |
78 | CONSTRUCTOR, |
79 | /** A static initializer. */ |
80 | STATIC_INIT, |
81 | /** An instance initializer. */ |
82 | INSTANCE_INIT, |
83 | |
84 | /** A type parameter. */ |
85 | TYPE_PARAMETER, |
86 | |
87 | /** |
88 | * An implementation-reserved element. This is not the element |
89 | * you are looking for. |
90 | */ |
91 | OTHER; |
92 | |
93 | |
94 | /** |
95 | * Returns {@code true} if this is a kind of class: |
96 | * either {@code CLASS} or {@code ENUM}. |
97 | * |
98 | * @return {@code true} if this is a kind of class |
99 | */ |
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 | } |