|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 枚举常量 | 字段 | 方法 | 详细信息: 枚举常量 | 字段 | 方法 | |||||||||
java.lang.Objectjava.lang.Enum<NestingKind>
javax.lang.model.element.NestingKind
public enum NestingKind
某一类型元素的嵌套种类 (nesting kind)。类型元素的种类有四种:top-level(顶层)、member(成员)、local(局部)和 anonymous(匿名)。嵌套种类 是一个非标准术语,在这里使用它是为了表示这种分类。
注意,在平台的未来版本中可能添加其他嵌套种类。
示例: 以下类是使用其嵌套种类注释的。
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import javax.lang.model.element.*;
import static javax.lang.model.element.NestingKind.*;
@Nesting(TOP_LEVEL)
public class NestingExamples {
@Nesting(MEMBER)
static class MemberClass1{}
@Nesting(MEMBER)
class MemberClass2{}
public static void main(String... argv) {
@Nesting(LOCAL)
class LocalClass{};
Class<?>[] classes = {
NestingExamples.class,
MemberClass1.class,
MemberClass2.class,
LocalClass.class
};
for(Class<?> clazz : classes) {
System.out.format("%s is %s%n",
clazz.getName(),
clazz.getAnnotation(Nesting.class).value());
}
}
}
@Retention(RUNTIME)
@interface Nesting {
NestingKind value();
}
| 枚举常量摘要 | |
|---|---|
ANONYMOUS
|
|
LOCAL
|
|
MEMBER
|
|
TOP_LEVEL
|
|
| 方法摘要 | |
|---|---|
boolean |
isNested()
此常量是否对应于嵌套类型元素?嵌套 (nested) 类型元素是任何非顶层的元素。 |
static NestingKind |
valueOf(String name)
返回带有指定名称的该类型的枚举常量。 |
static NestingKind[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
| 从类 java.lang.Enum 继承的方法 |
|---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
| 从类 java.lang.Object 继承的方法 |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| 枚举常量详细信息 |
|---|
public static final NestingKind TOP_LEVEL
public static final NestingKind MEMBER
public static final NestingKind LOCAL
public static final NestingKind ANONYMOUS
| 方法详细信息 |
|---|
public static final NestingKind[] values()
for(NestingKind c : NestingKind.values())
System.out.println(c);
public static NestingKind valueOf(String name)
指定要返回的枚举常量的名称。 -
如果该枚举类型没有带有指定名称的常量, - 则抛出 IllegalArgumentExceptionpublic boolean isNested()
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 枚举常量 | 字段 | 方法 | 详细信息: 枚举常量 | 字段 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。