Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.compiler/share/classes/javax/lang/model/element/NestingKind.java
41161 views
1
/*
2
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. 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. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle 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 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.
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
* &#64;Nesting(TOP_LEVEL)
47
* public class NestingExamples {
48
* &#64;Nesting(MEMBER)
49
* static class MemberClass1{}
50
*
51
* &#64;Nesting(MEMBER)
52
* class MemberClass2{}
53
*
54
* public static void main(String... argv) {
55
* &#64;Nesting(LOCAL)
56
* class LocalClass{};
57
*
58
* Class&lt;?&gt;[] classes = {
59
* NestingExamples.class,
60
* MemberClass1.class,
61
* MemberClass2.class,
62
* LocalClass.class
63
* };
64
*
65
* for(Class&lt;?&gt; clazz : classes) {
66
* System.out.format("%s is %s%n",
67
* clazz.getName(),
68
* clazz.getAnnotation(Nesting.class).value());
69
* }
70
* }
71
* }
72
*
73
* &#64;Retention(RUNTIME)
74
* &#64;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&eacute;
82
* @since 1.6
83
*/
84
public enum NestingKind {
85
/**
86
* A top-level class or interface, not contained within another
87
* class or interface.
88
*/
89
TOP_LEVEL,
90
91
/**
92
* A class or interface that is a named member of another class or
93
* interface.
94
* @jls 8.5 Member Class and Interface Declarations
95
*/
96
MEMBER,
97
98
/**
99
* A named class or interface declared within a construct other
100
* than a class or interface.
101
* @jls 14.3 Local Class Declarations
102
*/
103
LOCAL,
104
105
/**
106
* A class without a name.
107
* @jls 15.9.5 Anonymous Class Declarations
108
*/
109
ANONYMOUS;
110
111
/**
112
* Does this constant correspond to a nested type element?
113
* A <i>nested</i> type element is any that is not top-level.
114
* More specifically, an <i>inner</i> type element is any nested type element that
115
* is not {@linkplain Modifier#STATIC static}.
116
* @return whether or not the constant is nested
117
* @jls 14.3 Local Class Declarations
118
*/
119
public boolean isNested() {
120
return this != TOP_LEVEL;
121
}
122
}
123
124