All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.cdi.util.annotatedtypebuilder.AnnotationStore Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
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);
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy