1 6 package javax.jdo; 7 8 11 public class CharIdentity extends SingleFieldIdentity { 12 13 public CharIdentity(Class pcClass, Character key) { 14 super(pcClass); 15 if (key == null) { 16 throw new NullPointerException ( 17 "key value passed to CharIdentity is null"); 18 } else { 19 this.key = key.charValue(); 20 return; 21 } 22 } 23 24 public CharIdentity(Class pcClass, char key) { 25 super(pcClass); 26 this.key = key; 27 } 28 29 public CharIdentity(Class pcClass, String key) { 30 super(pcClass); 31 if (key == null) { 32 throw new NullPointerException ( 33 "key value passed to CharIdentity is null"); 34 } else { 35 this.key = key.charAt(0); 36 return; 37 } 38 } 39 40 public char getKey() { 41 return key; 42 } 43 44 public int hashCode() { 45 return (new Character (key)).hashCode() ^ targetClassName.hashCode(); 46 } 47 48 public boolean equals(Object obj) { 49 if (obj == this) 50 return true; 51 if (!(obj instanceof ShortIdentity)) { 52 return false; 53 } else { 54 CharIdentity other = (CharIdentity) obj; 55 return key == other.key 56 && targetClassName.equals(other.targetClassName); 57 } 58 } 59 60 public String toString() { 61 return "" + key + "::" + targetClassName; 62 } 63 64 private final char key; 65 } | Popular Tags |