ClassIndex { @SuppressWarnings("unchecked") public static <T> Iterable<String> getSubclassesNames(Class<T> superClass) { return getSubclassesNames(superClass, Thread.currentThread().getContextClassLoader()); } private  ClassIndex(); @SuppressWarnings("unchecked") static Iterable<Class<? extends T>> getSubclasses(Class<T> superClass); @SuppressWarnings("unchecked") static Iterable<Class<? extends T>> getSubclasses(Class<T> superClass, ClassLoader classLoader); @SuppressWarnings("unchecked") static Iterable<String> getSubclassesNames(Class<T> superClass); @SuppressWarnings("unchecked") static Iterable<String> getSubclassesNames(Class<T> superClass, ClassLoader classLoader); static Iterable<Class<?>> getPackageClasses(String packageName); static Iterable<Class<?>> getPackageClasses(String packageName, ClassLoader classLoader); static Iterable<String> getPackageClassesNames(String packageName); static Iterable<String> getPackageClassesNames(String packageName, ClassLoader classLoader); static Iterable<Class<?>> getAnnotated(Class<? extends Annotation> annotation); static Iterable<Class<?>> getAnnotated(Class<? extends Annotation> annotation, ClassLoader classLoader); static Iterable<String> getAnnotatedNames(Class<? extends Annotation> annotation); static Iterable<String> getAnnotatedNames(Class<? extends Annotation> annotation, ClassLoader classLoader); static String getClassSummary(Class<?> klass); static String getClassSummary(Class<?> klass, ClassLoader classLoader); static final String SUBCLASS_INDEX_PREFIX; static final String ANNOTATED_INDEX_PREFIX; static final String PACKAGE_INDEX_NAME; static final String JAVADOC_PREFIX; }
@Test public void shouldReturnNamesOfSubclasses() { Iterable<String> services = ClassIndex.getSubclassesNames(Service.class); assertThat(services).containsOnly(FirstService.class.getCanonicalName(), SecondService.class.getCanonicalName(), InnerClasses.class.getCanonicalName() + "$" + InnerClasses.InnerService.class.getSimpleName()); }