@Test public void getTypesAnnotatedWith() { Set<Class<?>> found = reflectionsToTest.getTypesAnnotatedWith(ReflectionsExampleUsageAnnotation.class); assertNotNull(found); assertEquals(2, found.size()); Set<String> sortedSet = new TreeSet<>(); for (Class<?> clazz : found) { sortedSet.add(clazz.toString()); } assertFound("class com.daimler.sechub.docgen.reflections.ReflectionsExampleClass1",sortedSet); assertFound("class com.daimler.sechub.docgen.reflections.ReflectionsExampleClass2",sortedSet); }
public Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation) { ensureScan(); synchronized (MONITOR) { Set<Class<?>> result = annotationClassToType.get(annotation); if (result != null) { return result; } Set<Class<?>> newResult = new LinkedHashSet<>(); visitEveryClass(new Visitor() { @Override public void visit(Class<?> clazz) { if (clazz.getAnnotation(annotation) != null) { newResult.add(clazz); } } }); annotationClassToType.put(annotation, newResult); return newResult; } }
Reflections { public Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation) { ensureScan(); synchronized (MONITOR) { Set<Class<?>> result = annotationClassToType.get(annotation); if (result != null) { return result; } Set<Class<?>> newResult = new LinkedHashSet<>(); visitEveryClass(new Visitor() { @Override public void visit(Class<?> clazz) { if (clazz.getAnnotation(annotation) != null) { newResult.add(clazz); } } }); annotationClassToType.put(annotation, newResult); return newResult; } } }
Reflections { public Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation) { ensureScan(); synchronized (MONITOR) { Set<Class<?>> result = annotationClassToType.get(annotation); if (result != null) { return result; } Set<Class<?>> newResult = new LinkedHashSet<>(); visitEveryClass(new Visitor() { @Override public void visit(Class<?> clazz) { if (clazz.getAnnotation(annotation) != null) { newResult.add(clazz); } } }); annotationClassToType.put(annotation, newResult); return newResult; } } Reflections(); }
Reflections { public Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation) { ensureScan(); synchronized (MONITOR) { Set<Class<?>> result = annotationClassToType.get(annotation); if (result != null) { return result; } Set<Class<?>> newResult = new LinkedHashSet<>(); visitEveryClass(new Visitor() { @Override public void visit(Class<?> clazz) { if (clazz.getAnnotation(annotation) != null) { newResult.add(clazz); } } }); annotationClassToType.put(annotation, newResult); return newResult; } } Reflections(); Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation); Set<Method> getMethodsAnnotatedWith(Class<? extends Annotation> annotation); Set<Field> getFieldsAnnotatedWith(Class<? extends Annotation> annotation); Set<Class<? extends T>> getSubTypesOf(Class<T> clazz); boolean isInspecting(Class<?> clazz); int getAmountOfInspectedClasses(); }
Reflections { public Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation) { ensureScan(); synchronized (MONITOR) { Set<Class<?>> result = annotationClassToType.get(annotation); if (result != null) { return result; } Set<Class<?>> newResult = new LinkedHashSet<>(); visitEveryClass(new Visitor() { @Override public void visit(Class<?> clazz) { if (clazz.getAnnotation(annotation) != null) { newResult.add(clazz); } } }); annotationClassToType.put(annotation, newResult); return newResult; } } Reflections(); Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation); Set<Method> getMethodsAnnotatedWith(Class<? extends Annotation> annotation); Set<Field> getFieldsAnnotatedWith(Class<? extends Annotation> annotation); Set<Class<? extends T>> getSubTypesOf(Class<T> clazz); boolean isInspecting(Class<?> clazz); int getAmountOfInspectedClasses();  }