com.github.nill14.utils.init.meta.AnnotationScanner Maven / Gradle / Ivy
package com.github.nill14.utils.init.meta;
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.stream.Stream;
import com.google.common.collect.Maps;
public class AnnotationScanner {
public static Map, Annotation> indexAnnotations(Annotation[] annotations) {
return indexAnnotations(Stream.of(annotations));
}
public static Map, Annotation> indexAnnotations(Stream annotations) {
return Maps.uniqueIndex(annotations.iterator(), a -> a.annotationType());
}
public static Map, Annotation> findAnnotations(Annotation[] annotations, Class extends Annotation> metaAnnotation) {
return findAnnotations(Stream.of(annotations), metaAnnotation);
}
public static Map, Annotation> findAnnotations(Stream annotations, Class extends Annotation> metaAnnotation) {
return indexAnnotations(annotations.filter(a -> a.annotationType().isAnnotationPresent(metaAnnotation)));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy