author | darcy |
Wed, 27 Sep 2017 14:23:41 -0700 | |
changeset 47283 | ce5fd3ba3fea |
parent 47216 | 71c04702a3d5 |
child 54952 | a978d86ac389 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
43567
d0d89c3da7be
8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents:
25874
diff
changeset
|
2 |
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package javax.lang.model.element; |
|
27 |
||
28 |
/** |
|
29 |
* The <i>nesting kind</i> of a type element. |
|
30 |
* Type elements come in four varieties: |
|
31 |
* top-level, member, local, and anonymous. |
|
32 |
* <i>Nesting kind</i> is a non-standard term used here to denote this |
|
33 |
* classification. |
|
34 |
* |
|
35 |
* <p>Note that it is possible additional nesting kinds will be added |
|
36 |
* in future versions of the platform. |
|
37 |
* |
|
38 |
* <p><b>Example:</b> The classes below are annotated with their nesting kind. |
|
39 |
* <blockquote><pre> |
|
40 |
* |
|
41 |
* import java.lang.annotation.*; |
|
42 |
* import static java.lang.annotation.RetentionPolicy.*; |
|
43 |
* import javax.lang.model.element.*; |
|
44 |
* import static javax.lang.model.element.NestingKind.*; |
|
45 |
* |
|
46 |
* @Nesting(TOP_LEVEL) |
|
47 |
* public class NestingExamples { |
|
48 |
* @Nesting(MEMBER) |
|
49 |
* static class MemberClass1{} |
|
50 |
* |
|
51 |
* @Nesting(MEMBER) |
|
52 |
* class MemberClass2{} |
|
53 |
* |
|
54 |
* public static void main(String... argv) { |
|
55 |
* @Nesting(LOCAL) |
|
56 |
* class LocalClass{}; |
|
57 |
* |
|
58 |
* Class<?>[] classes = { |
|
59 |
* NestingExamples.class, |
|
60 |
* MemberClass1.class, |
|
61 |
* MemberClass2.class, |
|
62 |
* LocalClass.class |
|
63 |
* }; |
|
64 |
* |
|
65 |
* for(Class<?> clazz : classes) { |
|
66 |
* System.out.format("%s is %s%n", |
|
67 |
* clazz.getName(), |
|
68 |
* clazz.getAnnotation(Nesting.class).value()); |
|
69 |
* } |
|
70 |
* } |
|
71 |
* } |
|
72 |
* |
|
73 |
* @Retention(RUNTIME) |
|
74 |
* @interface Nesting { |
|
75 |
* NestingKind value(); |
|
76 |
* } |
|
77 |
* </pre></blockquote> |
|
78 |
* |
|
79 |
* @author Joseph D. Darcy |
|
80 |
* @author Scott Seligman |
|
81 |
* @author Peter von der Ahé |
|
82 |
* @since 1.6 |
|
83 |
*/ |
|
84 |
public enum NestingKind { |
|
17548 | 85 |
/** |
86 |
* A top-level type, not contained within another type. |
|
87 |
*/ |
|
10 | 88 |
TOP_LEVEL, |
17548 | 89 |
|
90 |
/** |
|
91 |
* A type that is a named member of another type. |
|
43567
d0d89c3da7be
8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents:
25874
diff
changeset
|
92 |
* @jls 8.5 Member Type Declarations |
17548 | 93 |
*/ |
10 | 94 |
MEMBER, |
17548 | 95 |
|
96 |
/** |
|
97 |
* A named type declared within a construct other than a type. |
|
43567
d0d89c3da7be
8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents:
25874
diff
changeset
|
98 |
* @jls 14.3 Local Class Declarations |
17548 | 99 |
*/ |
10 | 100 |
LOCAL, |
17548 | 101 |
|
102 |
/** |
|
103 |
* A type without a name. |
|
43567
d0d89c3da7be
8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents:
25874
diff
changeset
|
104 |
* @jls 15.9.5 Anonymous Class Declarations |
17548 | 105 |
*/ |
10 | 106 |
ANONYMOUS; |
107 |
||
108 |
/** |
|
109 |
* Does this constant correspond to a nested type element? |
|
110 |
* A <i>nested</i> type element is any that is not top-level. |
|
43567
d0d89c3da7be
8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents:
25874
diff
changeset
|
111 |
* More specifically, an <i>inner</i> type element is any nested type element that |
10 | 112 |
* is not {@linkplain Modifier#STATIC static}. |
17548 | 113 |
* @return whether or not the constant is nested |
43567
d0d89c3da7be
8173676: Improvements to javax.annotation.processing and javax.lang.model doc
darcy
parents:
25874
diff
changeset
|
114 |
* @jls 14.3 Inner Classes and Enclosing Instances |
10 | 115 |
*/ |
116 |
public boolean isNested() { |
|
117 |
return this != TOP_LEVEL; |
|
118 |
} |
|
119 |
} |