public static Type [ ] getActualTypeArgumentsOfAnInterface ( Class < ? > classToSearch , Class < ? > interfaceToFind ) { Type [ ] types = findParameterizedTypes ( classToSearch , interfaceToFind ) ; if ( types == null ) throw new RuntimeException ( "Unable to find type arguments of " + interfaceToFind ) ; return types ; }
Given a class and an interfaces go through the class hierarchy to find the interface and return its type arguments .