public final class GenericTypeReflector extends Object
Modifier and Type | Method and Description |
---|---|
static Type |
getExactSuperType(Type type,
Class<?> searchClass)
Finds the most specific supertype of type whose erasure is searchClass.
|
public static Type getExactSuperType(Type type, Class<?> searchClass)
ParameterizedType
if searchClass is a real class or interface and
type has parameters for itGenericArrayType
if
searchClass is an array type, and type has type parameters for itClass
if type is a raw type, or has no type parameters for searchClassFor example, with
class StringList implements List<String>, getExactSuperType(StringList.class,
Collection.class) returns a ParameterizedType
representing Collection<String>.
type
- the type parameters.searchClass
- the type parameters.Copyright © 2020. All Rights Reserved.