1 22 package org.jboss.reflect.plugins; 23 24 import org.jboss.reflect.spi.AnnotationAttribute; 25 import org.jboss.reflect.spi.AnnotationInfo; 26 27 import java.util.HashMap ; 28 29 35 public class AnnotationInfoImpl extends InterfaceInfoImpl implements AnnotationInfo 36 { 37 38 private static final long serialVersionUID = 3546645408219542832L; 39 40 41 protected AnnotationAttribute[] attributes; 42 43 44 protected HashMap <String , AnnotationAttribute> attributeMap; 45 46 49 public AnnotationInfoImpl() 50 { 51 } 52 53 59 public AnnotationInfoImpl(String name, int modifiers) 60 { 61 super(name, modifiers, null); 62 } 63 64 69 public void setAttributes(AnnotationAttributeImpl[] attributes) 70 { 71 this.attributes = attributes; 72 if (attributes != null && attributes.length > 0) 73 { 74 this.attributes = attributes; 75 attributeMap = new HashMap <String , AnnotationAttribute>(); 76 for (int i = 0; i < attributes.length; i++) 77 { 78 attributeMap.put(attributes[i].getName(), attributes[i]); 79 } 80 } 81 } 82 83 public String getName() 84 { 85 return name; 86 } 87 88 public int getModifiers() 89 { 90 return modifiers; 91 } 92 93 public AnnotationAttribute[] getAttributes() 94 { 95 return attributes; 96 } 97 98 public AnnotationAttribute getAttribute(String name) 99 { 100 if (attributeMap == null) 101 return null; 102 return attributeMap.get(name); 103 } 104 105 public boolean equals(Object o) 106 { 107 if (this == o) return true; 108 if (!(o instanceof AnnotationInfoImpl)) return false; 109 110 final AnnotationInfoImpl annotationInfo = (AnnotationInfoImpl) o; 111 112 if (!name.equals(annotationInfo.name)) return false; 113 114 return true; 115 } 116 117 public int hashCode() 118 { 119 return name.hashCode(); 120 } 121 } 122 | Popular Tags |