ReflectionUtil { public static Stream<Class<?>> traverseAncestors(Class<?> clazz) { if (clazz.getSuperclass() == null) { return Stream.of(clazz); } else { return Stream.concat( Stream.of(clazz), Stream.concat( traverseAncestors(clazz.getSuperclass()), Stream.of(clazz.getInterfaces()) ) ).distinct(); } } private  ReflectionUtil(); static Stream<Field> traverseFields(Class<?> clazz); static Stream<Method> traverseMethods(Class<?> clazz); static Stream<Class<?>> traverseAncestors(Class<?> clazz); static MissingArgumentStrategy missingArgumentStrategy(Executable executable); static Optional<T> tryToCreate(Class<T> clazz, Properties properties, List<Object> instances, Set<Class<?>> allInjectableTypes, InjectorProxy injectorProxy); @SuppressWarnings("unchecked") static String errorMsg(Class<T> c, List<Object> instances); static Optional<Object> parse(Type type, String serialized);  }
@Test void traverseAncestors() { final Set<Class<?>> expected = Stream.of(Object.class, Foo.class, Bar.class).collect(toSet()); final Set<Class<?>> actual = ReflectionUtil.traverseAncestors(Bar.class) .collect(toSet()); assertEquals(expected, actual); }