1 22 package org.jboss.reflect.plugins; 23 24 import java.io.Serializable ; 25 26 import org.jboss.reflect.spi.ClassValue; 27 import org.jboss.reflect.spi.TypeInfo; 28 import org.jboss.util.JBossObject; 29 30 36 public class ClassValueImpl extends JBossObject implements ClassValue, Serializable 37 { 38 39 private static final long serialVersionUID = 3256721801307566649L; 40 41 42 protected String value; 43 44 45 protected TypeInfo type; 46 47 48 protected int hash = -1; 49 50 53 public ClassValueImpl() 54 { 55 } 56 57 63 public ClassValueImpl(String value, TypeInfo type) 64 { 65 this.value = value; 66 this.type = type; 67 calculateHash(); 68 } 69 70 public String getValue() 71 { 72 return value; 73 } 74 75 public TypeInfo getType() 76 { 77 return type; 78 } 79 80 public boolean equals(Object o) 81 { 82 if (this == o) return true; 83 if (!(o instanceof ClassValueImpl)) return false; 84 85 final ClassValueImpl classValue = (ClassValueImpl) o; 86 87 if (!type.equals(classValue.type)) return false; 88 if (!value.equals(classValue.value)) return false; 89 90 return true; 91 } 92 93 public int hashCode() { return hash; } 94 95 98 protected void calculateHash() 99 { 100 int result; 101 result = (value != null) ? value.hashCode() : 0; 102 result = 29 * result + type.hashCode(); 103 hash = result; 104 } 105 } 106 | Popular Tags |