1 22 package org.jboss.reflect.plugins; 23 24 import java.io.Serializable ; 25 26 import org.jboss.reflect.spi.EnumConstantInfo; 27 import org.jboss.reflect.spi.EnumInfo; 28 import org.jboss.util.JBossObject; 29 30 36 public class EnumConstantInfoImpl extends JBossObject implements EnumConstantInfo, Serializable 37 { 38 39 private static final long serialVersionUID = 3761411923568243761L; 40 41 42 protected String name; 43 44 45 protected EnumInfo declaring; 46 47 48 protected int hash = -1; 49 50 53 public EnumConstantInfoImpl() 54 { 55 } 56 57 63 public EnumConstantInfoImpl(String name, EnumInfo declaring) 64 { 65 this.name = name; 66 this.declaring = declaring; 67 calculateHash(); 68 } 69 70 75 public String getName() 76 { 77 return name; 78 } 79 80 85 public EnumInfo getDeclaring() 86 { 87 return declaring; 88 } 89 90 public boolean equals(Object o) 91 { 92 if (this == o) return true; 93 if (!(o instanceof EnumConstantInfoImpl)) return false; 94 95 final EnumConstantInfoImpl enumConstantInfo = (EnumConstantInfoImpl) o; 96 97 if (name != enumConstantInfo.name) 98 return false; 99 if (!declaring.equals(enumConstantInfo.declaring)) 100 return false; 101 102 return true; 103 } 104 105 public int hashCode() { return hash; } 106 107 110 protected void calculateHash() 111 { 112 int result = name.hashCode(); 113 result = 29 * result + declaring.hashCode(); 114 hash = result; 115 } 116 } 117 | Popular Tags |