src/share/classes/javax/lang/model/element/NestingKind.java

changeset 1
9a66ca7c79fa
child 554
9d9f26857129
equal deleted inserted replaced
-1:000000000000 1:9a66ca7c79fa
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 <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 TOP_LEVEL,
86 MEMBER,
87 LOCAL,
88 ANONYMOUS;
89
90 /**
91 * Does this constant correspond to a nested type element?
92 * A <i>nested</i> type element is any that is not top-level.
93 * An <i>inner</i> type element is any nested type element that
94 * is not {@linkplain Modifier#STATIC static}.
95 */
96 public boolean isNested() {
97 return this != TOP_LEVEL;
98 }
99 }

mercurial