1 22 package org.jboss.reflect.plugins; 23 24 import org.jboss.reflect.spi.AnnotatedInfo; 25 import org.jboss.reflect.spi.AnnotationValue; 26 import org.jboss.reflect.spi.AnnotationInfo; 27 import org.jboss.util.JBossObject; 28 29 import java.io.Serializable ; 30 import java.util.HashMap ; 31 32 38 public class AnnotationHolder extends JBossObject implements AnnotatedInfo, Serializable 39 { 40 41 private static final long serialVersionUID = 3546645408219542832L; 42 43 44 protected AnnotationValue[] annotationsArray; 45 46 47 protected HashMap <String , AnnotationValue> annotationMap; 48 49 52 public AnnotationHolder() 53 { 54 } 55 56 61 public AnnotationHolder(AnnotationValue[] annotations) 62 { 63 setupAnnotations(annotations); 64 } 65 66 public AnnotationValue[] getAnnotations() 67 { 68 return annotationsArray; 69 } 70 71 public AnnotationValue getAnnotation(String name) 72 { 73 if (annotationMap == null) return null; 74 return annotationMap.get(name); 75 } 76 77 public boolean isAnnotationPresent(String name) 78 { 79 if (annotationMap == null) return false; 80 return annotationMap.containsKey(name); 81 } 82 83 88 protected void setupAnnotations(AnnotationValue[] annotations) 89 { 90 if (annotations != null && annotations.length > 0) 91 { 92 this.annotationsArray = annotations; 93 annotationMap = new HashMap <String , AnnotationValue>(); 94 for (int i = 0; i < annotations.length; i++) 95 { 96 AnnotationInfo type = annotations[i].getAnnotationType(); 97 annotationMap.put(type.getName(), annotations[i]); 98 } 99 } 100 } 101 } 102 | Popular Tags |