1 25 26 package org.objectweb.jonas.jtests.beans.relation.s2pkcomp; 27 28 31 public class Pk implements java.io.Serializable 32 { 33 public String id1; 34 public int id2; 35 36 private int hashCode = -1; 37 38 public Pk() { 39 } 40 41 public Pk(String id1, int id2) 42 { 43 this.id1 = id1; 44 this.id2 = id2; 45 } 46 47 public boolean equals(Object other) 48 { 49 if (other == null) { 50 return false; 51 } 52 if (other == this) { 53 return true; 54 } 55 if (!(other instanceof Pk)) { 56 return false; 57 } 58 Pk otherPk = (Pk)other; 59 return ((id1.equals(otherPk.id1)) && (id2==otherPk.id2)); 60 } 61 62 public int hashCode() { 63 if (hashCode == -1) { 64 hashCode = id1.hashCode() ^ new Integer (id2).hashCode(); 65 } 66 return hashCode; 67 } 68 69 public String toString() { 70 return("(" + id1 + "-" + id2 + ")"); 71 } 72 } 73 | Popular Tags |