public abstract class TypeReflectionUtils extends Object
com.googlecode.gentyref.GenericTypeReflector
.
All the unused functions have been removed and only the getExactSuperType(Type, Class)
has remained. The private functions used by getExactSuperType(Type, Class)
have also been tailored to our
exact needs.
The credits for creating this functionality however go to Wouter Coekaerts, which created this functionality in the
'com.googlecode.gentyref' library with group id 'gentyref'.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
searchClass
For example, with class StringList implements List<String>,
getExactSuperType(StringList.class, Collection.class)
returns a ParameterizedType
representing Collection<String>.
type
- The type to searchsearchClass
- The erased type of the super class to findtype
, whose erased type is searchClass
Copyright © 2010–2020. All rights reserved.