R
- このビジターのメソッドの戻り型。結果を返すことを必要としないビジターのVoid
を使用する。P
- このビジターのメソッドに追加するパラメータの型。追加のパラメータを必要としないビジターのVoid
を使用する。public interface TypeVisitor<R,P>
accept
メソッドに渡されると、その型にもっとも適したvisitXYZメソッドが呼び出されます。
このインタフェースを実装するクラスは、追加パラメータp
がnull
のときにNullPointerException
をスローする場合としない場合があります。詳細については、クラスの実装に関するドキュメントを参照してください。
警告: Java(tm)プログラミング言語の将来のバージョンに現在は未知の新しい言語構造が追加される場合、それらを格納するために、このインタフェースにメソッドが追加される可能性があります。したがって、このインタフェースを直接実装するビジター・クラスは、プラットフォームの将来のバージョンでソースの互換性がなくなる可能性があります。このようなソースの非互換性を回避するために、ビジターの実装では、このインタフェースを実装する適切な抽象ビジター・クラスを拡張することをお薦めします。ただし、APIは通常、抽象クラスのいずれかではなく、パラメータの型や戻り型などとして、このビジター・インタフェースを使用します。
新しい言語コンストラクトを格納するためのメソッドは、デフォルト・メソッドとして追加された場合、ソースと互換性のある方法で追加されることがあります。ただし、Java SE 8以降のリリースでのみ利用可能なデフォルト・メソッド、およびJava SE 8にバンドルされているjavax.lang.model.*
パッケージは、Java SE 7でも実行可能でなければなりません。したがって、Java SE 8の言語機能に対応するためにjavax.lang.model.*
を拡張する場合、デフォルト・メソッドは使用できません。ただし、javax.lang.model.*
パッケージの今後のリビジョンで、Java SE 8以降のプラットフォーム・バージョンだけで実行が求められるようになれば、デフォルト・メソッドを使用できます。
修飾子と型 | メソッドと説明 |
---|---|
R |
visit(TypeMirror t)
v.visit(t, null) と同等の簡易メソッドです。 |
R |
visit(TypeMirror t, P p)
型をビジットします。
|
R |
visitArray(ArrayType t, P p)
配列型をビジットします。
|
R |
visitDeclared(DeclaredType t, P p)
宣言された型をビジットします。
|
R |
visitError(ErrorType t, P p)
エラー型をビジットします。
|
R |
visitExecutable(ExecutableType t, P p)
実行可能型をビジットします。
|
R |
visitIntersection(IntersectionType t, P p)
共通部分型をビジットします。
|
R |
visitNoType(NoType t, P p)
NoType インスタンスをビジットします。 |
R |
visitNull(NullType t, P p)
null型をビジットします。
|
R |
visitPrimitive(PrimitiveType t, P p)
プリミティブ型をビジットします。
|
R |
visitTypeVariable(TypeVariable t, P p)
型変数をビジットします。
|
R |
visitUnion(UnionType t, P p)
共用体型をビジットします。
|
R |
visitUnknown(TypeMirror t, P p)
未知の種類の型をビジットします。
|
R |
visitWildcard(WildcardType t, P p)
ワイルドカード型をビジットします。
|
R visit(TypeMirror t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visit(TypeMirror t)
v.visit(t, null)
と同等の簡易メソッドです。t
- ビジットする要素R visitPrimitive(PrimitiveType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitNull(NullType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitArray(ArrayType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitDeclared(DeclaredType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitError(ErrorType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitTypeVariable(TypeVariable t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitWildcard(WildcardType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitExecutable(ExecutableType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitNoType(NoType t, P p)
NoType
インスタンスをビジットします。t
- ビジットする型p
- ビジター指定のパラメータR visitUnknown(TypeMirror t, P p)
TypeMirror
階層に追加された場合に発生します。t
- ビジットする型p
- ビジター指定のパラメータUnknownTypeException
- 必要に応じてビジターの実装はこの例外をスローできるR visitUnion(UnionType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータR visitIntersection(IntersectionType t, P p)
t
- ビジットする型p
- ビジター指定のパラメータ バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2018, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。