org.infinispan.cdi.util.annotatedtypebuilder.AnnotationStore Maven / Gradle / Ivy
package org.infinispan.cdi.util.annotatedtypebuilder;
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.Set;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet;
/**
* A helper class used to hold annotations on a type or member.
*
* @author Stuart Douglas
*/
class AnnotationStore {
private final Map, Annotation> annotationMap;
private final Set annotationSet;
AnnotationStore(Map, Annotation> annotationMap, Set annotationSet) {
this.annotationMap = annotationMap;
this.annotationSet = unmodifiableSet(annotationSet);
}
AnnotationStore() {
this.annotationMap = emptyMap();
this.annotationSet = emptySet();
}
T getAnnotation(Class annotationType) {
return annotationType.cast(annotationMap.get(annotationType));
}
Set getAnnotations() {
return annotationSet;
}
boolean isAnnotationPresent(Class annotationType) {
return annotationMap.containsKey(annotationType);
}
}