©
本文档使用
php.cn手册 发布
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 枚举常量 | 字段 | 方法 | 详细信息: 枚举常量 | 字段 | 方法 |
1 2 3 |
|
1 |
|
某一类型元素的嵌套种类 (nesting kind)。类型元素的种类有四种:top-level(顶层)、member(成员)、local(局部)和 anonymous(匿名)。嵌套种类 是一个非标准术语,在这里使用它是为了表示这种分类。
注意,在平台的未来版本中可能添加其他嵌套种类。
示例: 以下类是使用其嵌套种类注释的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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 |
枚举常量详细信息 |
---|
1 |
|
1 |
|
1 |
|
1 |
|
方法详细信息 |
---|
1 |
|
1 2 |
|
1 |
|
指定要返回的枚举常量的名称。
-
如果该枚举类型没有带有指定名称的常量,
- 则抛出 IllegalArgumentException1 |
|
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 枚举常量 | 字段 | 方法 | 详细信息: 枚举常量 | 字段 | 方法 |
版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。