|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 列舉常數 | 欄位 | 方法 | 詳細資訊: 列舉常數 | 欄位 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。