1 22 package org.jboss.reflect.plugins; 23 24 import java.io.Serializable ; 25 26 import org.jboss.reflect.spi.EnumValue; 27 import org.jboss.reflect.spi.TypeInfo; 28 import org.jboss.util.JBossObject; 29 30 36 public class EnumValueImpl extends JBossObject implements EnumValue, Serializable 37 { 38 39 private static final long serialVersionUID = 4120848858889662517L; 40 41 42 protected TypeInfo type; 43 44 45 protected String value; 46 47 48 protected int hash = -1; 49 50 53 public EnumValueImpl() 54 { 55 } 56 57 63 public EnumValueImpl(TypeInfo type, String value) 64 { 65 this.type = type; 66 this.value = value; 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 EnumValueImpl)) return false; 84 85 final EnumValueImpl enumValue = (EnumValueImpl) o; 86 87 if (type != null ? !type.equals(enumValue.type) : enumValue.type != null) return false; 88 if (value != null ? !value.equals(enumValue.value) : enumValue.value != null) return false; 89 90 return true; 91 } 92 93 public int hashCode() 94 { 95 return hash; 96 } 97 98 101 protected void calculateHash() 102 { 103 int result; 104 result = (type != null ? type.hashCode() : 0); 105 result = 29 * result + (value != null ? value.hashCode() : 0); 106 hash = result; 107 } 108 } 109 | Popular Tags |