T
- 汎用型パラメーター。public class GenericType<T> extends ObjectSE
T
を表します。実際の型パラメーターを使用して汎用型を表すオブジェクトのインラインインスタンス化をサポートします。パラメーター化された型を表すオブジェクトは、GenericType
をサブクラス化することで取得できます。または、GenericType(java.lang.reflect.Type)
を使用し、actual (parameterized) type
を手動で指定して、具体的なパラメーター化された型を表すオブジェクトを作成することもできます。例:
GenericType<List<String>> stringListType = new GenericType<List<String>>() {};
または:
public class MyGenericType extends GenericType<List<String>> { ... } ... MyGenericType stringListType = new MyGenericType();
Java 型消去の制限により、パラメーター化された型情報は、インスタンスの作成中だけでなく、サブクラスで指定する必要があることに注意してください。例: 次の場合は IllegalArgumentException
SE がスローされます:
public class MyGenericType<T> extends GenericType<T> { ... } ... // The type is only specified on instance, not in a sub-class MyGenericType<List<String>> stringListType = new MyGenericType<List<String>>();
修飾子 | コンストラクターと説明 |
---|---|
protected | GenericType() 型パラメーターからジェネリクス型とクラスを派生させて、新しいジェネリクス型を構築します。 |
| GenericType(TypeSE genericType) 新しいジェネリクス型を構築し、ジェネリクス型情報を提供してクラスを派生させます。 |
修飾子と型 | メソッドと説明 |
---|---|
boolean | equals(ObjectSE obj) |
static GenericType | forInstance(ObjectSE instance) Java instance から generic type を作成します。 |
ClassSE<?> | getRawType() この汎用型インスタンスによって表される型を宣言したクラスまたはインターフェースを表すオブジェクトを返します。 |
TypeSE | getType() 汎用型インスタンスによって表される型を取得します。 |
int | hashCode() |
StringSE | toString() |
cloneSE, finalizeSE, getClassSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
protected GenericType()
IllegalArgumentExceptionSE
- ジェネリクス型のパラメーター値がどのサブクラスからも提供されていない場合。public GenericType(TypeSE genericType)
genericType
- ジェネリクス型。IllegalArgumentExceptionSE
- genericType が null
であるか、生の型が Class
のインスタンスである Class
または ParameterizedType
SE のインスタンスでない場合。public static GenericType forInstance(ObjectSE instance)
instance
から generic type
を作成します。 提供されたインスタンスが GenericEntity
の場合、ジェネリクス型は GenericEntity.getType()
を使用して計算されます。それ以外の場合は、instance.getClass()
が使用されます。
instance
- GenericType
記述を作成する必要がある Java インスタンス。instance
を説明する GenericType
。public final TypeSE getType()
public final ClassSE<?> getRawType()
public int hashCode()
ObjectSE
の hashCodeSE
public StringSE toString()
ObjectSE
の toStringSE
Copyright © 2019 Eclipse Foundation.
Use is subject to license terms.