1 22 package org.jboss.reflect.plugins; 23 24 import java.io.Serializable ; 25 import java.util.HashMap ; 26 27 import org.jboss.reflect.spi.AnnotationInfo; 28 import org.jboss.reflect.spi.AnnotationValue; 29 import org.jboss.reflect.spi.TypeInfo; 30 import org.jboss.reflect.spi.Value; 31 import org.jboss.util.JBossObject; 32 33 39 public class AnnotationValueImpl extends JBossObject implements AnnotationValue, Serializable 40 { 41 42 private static final long serialVersionUID = 3257290210164289843L; 43 44 45 protected AnnotationInfo annotationType; 46 47 48 protected HashMap attributeValues; 49 50 51 protected int hash = -1; 52 53 56 public AnnotationValueImpl() 57 { 58 } 59 60 66 public AnnotationValueImpl(AnnotationInfo annotationType, HashMap attributeValues) 67 { 68 this.annotationType = annotationType; 69 this.attributeValues = attributeValues; 70 calculateHash(); 71 } 72 73 public AnnotationInfo getAnnotationType() 74 { 75 return annotationType; 76 } 77 78 public Value getValue(String attributeName) 79 { 80 return (Value) attributeValues.get(attributeName); 81 } 82 83 public TypeInfo getType() 84 { 85 return annotationType; 86 } 87 88 public boolean equals(Object o) 89 { 90 if (this == o) return true; 91 if (!(o instanceof AnnotationValueImpl)) return false; 92 93 final AnnotationValueImpl annotationValue = (AnnotationValueImpl) o; 94 95 if (!annotationType.equals(annotationValue.annotationType)) return false; 96 if (!attributeValues.equals(annotationValue.attributeValues)) return false; 97 98 return true; 99 } 100 101 public int hashCode() 102 { 103 return hash; 104 } 105 106 109 protected void calculateHash() 110 { 111 int result; 112 result = (annotationType != null) ? annotationType.hashCode() : 0; 113 result = 29 * result + attributeValues.hashCode(); 114 hash = result; 115 } 116 } 117 | Popular Tags |