I was wondering if there was an easy way of determining the complete list of Types that a Java class extends or implements recursively?
for instance:
cla
The key you want is in the Class#getSuperclass()
method:
public static Set> stuff(Class> target) {
Set> classesInterfaces = new HashSet<>();
classesInterfaces.add(target);
classesInterfaces.addAll(Arrays.asList(target.getInterfaces());
Class> superClass = target.getSuperclass();
if(superClass != null)
classesInterfaces.addAll(stuff(superClass));
}