Package org.axonframework.common
Class TypeReflectionUtils
java.lang.Object
org.axonframework.common.TypeReflectionUtils
Utility class for doing reflection on types.
This TypeReflectionUtils is a trimmed down copy of the
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'.- Since:
- 3.2
- Author:
- Wouter Coekaerts invalid input: '<'wouter@coekaerts.be>, Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionstatic TypegetExactSuperType(Type type, Class<?> searchClass) Finds the most specific supertype of type whose erasure is searchClass.
-
Method Details
-
getExactSuperType
Finds the most specific supertype of type whose erasure is searchClass. In other words, returns a type representing the class searchClass plus its exact type parameters in type.- Returns an instance of
ParameterizedTypeif searchClass is a real class or interface and type has parameters for it - Returns an instance of
GenericArrayTypeif searchClass is an array type, and type has type parameters for it - Returns an instance of
Classif type is a raw type, or has no type parameters for searchClass - Returns null if searchClass is not a superclass of type.
For example, with class StringList implements List<String>, getExactSuperType(StringList.class, Collection.class) returns a
ParameterizedTyperepresenting Collection<String>.- Parameters:
type- The type to searchsearchClass- The erased type of the super class to find- Returns:
- The supertype of
type, whose erased type issearchClass
- Returns an instance of
-