/** * Get the names of annotations and meta-annotations on this class. This is equivalent to the reflection call * Class#getAnnotations(), except that it does not require calling the classloader, and it returns * meta-annotations as well as annotations. * * @return the sorted list of names of annotations and meta-annotations on this class or interface, or * meta-annotations if this is an annotation. Returns the empty list if none. */ public List<String> getNamesOfAnnotations() { return getClassNames(getAnnotations()); }
/** * Returns those annotations which have themselves been annotated as "Inherited". */ private List<ClassInfo> selectInheritedAnnotations(Collection<ClassInfo> classes) { return classes.stream() .flatMap(cls -> cls.getAnnotations().stream()) .filter(ann -> inheritedAnnotations.contains(ann.getClassName())) .collect(toList()); }
private Set<ClassInfo> readInterfaceAnnotationsFor(ClassInfo classInfo) { Set<ClassInfo> annotations = new HashSet<>(classInfo.getAnnotations()); annotations.addAll(selectInheritedAnnotations(classInfo.getSuperinterfaces())); return annotations; }
private Set<ClassInfo> readClassAnnotationsFor(ClassInfo classInfo) { Set<ClassInfo> annotations = new HashSet<>(classInfo.getAnnotations()); annotations.addAll(selectInheritedAnnotations(classInfo.getSuperclasses())); annotations.addAll(selectInheritedAnnotations(classInfo.getImplementedInterfaces())); return annotations; }