/** * Retrieves all superclasses and interfaces recursively. * * @param clazz the class to start the search with * @param classes list of classes to which to add all found super types matching * the given filters * @param filters filters applying for the search */ private static <T> void getHierarchy(Class<? super T> clazz, List<Class<? super T>> classes, Iterable<Filter> filters) { for ( Class<? super T> current = clazz; current != null; current = current.getSuperclass() ) { if ( classes.contains( current ) ) { return; } if ( acceptedByAllFilters( current, filters ) ) { classes.add( current ); } for ( Class<?> currentInterface : current.getInterfaces() ) { //safe since interfaces are super-types @SuppressWarnings("unchecked") Class<? super T> currentInterfaceCasted = (Class<? super T>) currentInterface; getHierarchy( currentInterfaceCasted, classes, filters ); } } }
/** * Retrieves all superclasses and interfaces recursively. * * @param clazz the class to start the search with * @param classes list of classes to which to add all found super types matching * the given filters * @param filters filters applying for the search */ private static <T> void getHierarchy(Class<? super T> clazz, List<Class<? super T>> classes, Iterable<Filter> filters) { for ( Class<? super T> current = clazz; current != null; current = current.getSuperclass() ) { if ( classes.contains( current ) ) { return; } if ( acceptedByAllFilters( current, filters ) ) { classes.add( current ); } for ( Class<?> currentInterface : current.getInterfaces() ) { //safe since interfaces are super-types @SuppressWarnings("unchecked") Class<? super T> currentInterfaceCasted = (Class<? super T>) currentInterface; getHierarchy( currentInterfaceCasted, classes, filters ); } } }