|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | 列挙型定数 | フィールド | メソッド | 詳細: 列挙型定数 | フィールド | メソッド | |||||||||
java.lang.Objectjava.lang.Enum<NestingKind>
javax.lang.model.element.NestingKind
public enum NestingKind
型要素の「入れ子の種類」です。型要素には、トップレベル、メンバー、ローカル、および匿名の 4 種類があります。「入れ子の種類」は、この分類を示すためにここだけで使用する非標準の用語です。
プラットフォームの将来のバージョンで、その他の入れ子の種類が追加される可能性があることに注意してください。
例: 次のクラスでは、そのクラスの入れ子の種類が注釈で示されています。
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()
この定数と、入れ子にされた型要素の対応関係は次のとおりです。 |
static NestingKind |
valueOf(String name)
指定した名前を持つこの型の列挙型定数を返します。 |
static NestingKind[] |
values()
この列挙型の定数を含む配列を宣言されている順序で返します。 |
| クラス 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 NestingKind[] values()
for (NestingKind c : NestingKind.values()) System.out.println(c);
public static NestingKind valueOf(String name)
name - 返される列挙型定数の名前
IllegalArgumentException - 指定された名前を持つ定数を
この列挙型が持っていない場合
NullPointerException - 引数が null の場合public boolean isNested()
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | 列挙型定数 | フィールド | メソッド | 詳細: 列挙型定数 | フィールド | メソッド | |||||||||
Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。