1 22 package org.jboss.reflect.plugins.javassist; 23 24 import java.util.HashMap ; 25 26 import javassist.CtClass; 27 28 import org.jboss.reflect.plugins.AnnotationAttributeImpl; 29 import org.jboss.reflect.plugins.AnnotationInfoImpl; 30 import org.jboss.reflect.spi.AnnotationAttribute; 31 import org.jboss.reflect.spi.AnnotationInfo; 32 33 38 public class JavassistAnnotationInfo extends JavassistTypeInfo implements AnnotationInfo 39 { 40 41 private static final long serialVersionUID = 3546645408219542832L; 42 43 44 protected AnnotationAttribute[] attributes; 45 46 47 protected HashMap <String , AnnotationAttribute> attributeMap; 48 49 public JavassistAnnotationInfo(JavassistTypeInfoFactoryImpl factory, CtClass ctClass, Class <? extends Object > clazz) 50 { 51 super(factory, ctClass, clazz); 52 } 53 54 59 public void setAttributes(AnnotationAttributeImpl[] attributes) 60 { 61 this.attributes = attributes; 62 if (attributes != null && attributes.length > 0) 63 { 64 this.attributes = attributes; 65 attributeMap = new HashMap <String , AnnotationAttribute>(); 66 for (int i = 0; i < attributes.length; i++) 67 { 68 attributeMap.put(attributes[i].getName(), attributes[i]); 69 } 70 } 71 } 72 73 public AnnotationAttribute[] getAttributes() 74 { 75 return attributes; 76 } 77 78 public AnnotationAttribute getAttribute(String name) 79 { 80 if (attributeMap == null) 81 return null; 82 return attributeMap.get(name); 83 } 84 85 public boolean equals(Object o) 86 { 87 if (this == o) return true; 88 if (!(o instanceof AnnotationInfoImpl)) return false; 89 90 final AnnotationInfoImpl annotationInfo = (AnnotationInfoImpl) o; 91 92 if (!getName().equals(annotationInfo.getName())) return false; 93 94 return true; 95 } 96 97 public int hashCode() 98 { 99 return getName().hashCode(); 100 } 101 102 } 103 | Popular Tags |