1 package org.hibernate.test.legacy; 3 4 import java.io.Serializable ; 5 6 public class CompositeElement implements Comparable , Serializable { 7 private String foo; 8 private String bar; 9 13 public String getBar() { 14 return bar; 15 } 16 17 21 public String getFoo() { 22 return foo; 23 } 24 25 29 public void setBar(String bar) { 30 this.bar = bar; 31 } 32 33 37 public void setFoo(String foo) { 38 this.foo = foo; 39 } 40 41 44 public int compareTo(Object o) { 45 return ( (CompositeElement) o ).foo.compareTo(foo); 46 } 47 48 public int hashCode() { 49 return foo.hashCode() + bar.hashCode(); 50 } 51 52 public boolean equals(Object that) { 53 CompositeElement ce = (CompositeElement) that; 54 return ce.bar.equals(bar) && ce.foo.equals(foo); 55 } 56 57 } 58 | Popular Tags |