1 22 package org.jboss.reflect.plugins; 23 24 import java.io.Serializable ; 25 26 import org.jboss.reflect.spi.AnnotationAttribute; 27 import org.jboss.reflect.spi.TypeInfo; 28 import org.jboss.reflect.spi.Value; 29 import org.jboss.util.JBossObject; 30 31 37 public class AnnotationAttributeImpl extends JBossObject implements AnnotationAttribute, Serializable 38 { 39 40 private static final long serialVersionUID = 3546645408219542832L; 41 42 43 protected String name; 44 45 46 protected TypeInfo type; 47 48 49 protected Value defaultValue; 50 51 52 protected int hash = -1; 53 54 57 public AnnotationAttributeImpl() 58 { 59 } 60 61 68 public AnnotationAttributeImpl(String name, TypeInfo type, Value defaultValue) 69 { 70 this.name = name; 71 this.type = type; 72 this.defaultValue = defaultValue; 73 calcHashCode(); 74 } 75 76 public String getName() 77 { 78 return name; 79 } 80 81 public TypeInfo getType() 82 { 83 return type; 84 } 85 86 public Value getDefaultValue() 87 { 88 return defaultValue; 89 } 90 91 public boolean equals(Object obj) 92 { 93 if (this == obj) 94 return true; 95 if (obj == null || obj instanceof AnnotationAttributeImpl == false) 96 return false; 97 98 final AnnotationAttributeImpl other = (AnnotationAttributeImpl) obj; 99 100 if (!name.equals(other.name)) 101 return false; 102 if (!type.equals(other.type)) 103 return false; 104 105 return true; 106 } 107 108 public int hashCode() 109 { 110 return hash; 111 } 112 113 116 protected void calcHashCode() 117 { 118 int result; 119 result = name.hashCode(); 120 result = 29 * result + type.hashCode(); 121 hash = result; 122 } 123 } 124 | Popular Tags |