Class GenericsUtil


  • public class GenericsUtil
    extends java.lang.Object
    Author:
    Nathan Sweet
    • Constructor Summary

      Constructors 
      Constructor Description
      GenericsUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.reflect.Type resolveType​(java.lang.Class fromClass, java.lang.Class toClass, java.lang.reflect.Type type)
      Returns the class for the specified type after replacing any type variables using the class hierarchy between the specified classes.
      static java.lang.reflect.Type[] resolveTypeParameters​(java.lang.Class fromClass, java.lang.Class toClass, java.lang.reflect.Type type)
      Resolves type variables for the type parameters of the specified type by using the class hierarchy between the specified classes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GenericsUtil

        public GenericsUtil()
    • Method Detail

      • resolveType

        public static java.lang.reflect.Type resolveType​(java.lang.Class fromClass,
                                                         java.lang.Class toClass,
                                                         java.lang.reflect.Type type)
        Returns the class for the specified type after replacing any type variables using the class hierarchy between the specified classes.
        Parameters:
        toClass - Must be a sub class of fromClass.
      • resolveTypeParameters

        public static java.lang.reflect.Type[] resolveTypeParameters​(java.lang.Class fromClass,
                                                                     java.lang.Class toClass,
                                                                     java.lang.reflect.Type type)
        Resolves type variables for the type parameters of the specified type by using the class hierarchy between the specified classes.
        Parameters:
        toClass - Must be a sub class of fromClass.
        Returns:
        Null if the type has no type parameters, else contains Class entries for type parameters that were resolved and TypeVariable entries for type parameters that couldn't be resolved.