KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > legacy > CompositeElement


1 //$Id: CompositeElement.java,v 1.2 2005/05/21 14:22:15 oneovthafew Exp $
2
package org.hibernate.test.legacy;
3
4 import java.io.Serializable JavaDoc;
5
6 public class CompositeElement implements Comparable JavaDoc, Serializable JavaDoc {
7     private String JavaDoc foo;
8     private String JavaDoc bar;
9     /**
10      * Returns the bar.
11      * @return String
12      */

13     public String JavaDoc getBar() {
14         return bar;
15     }
16
17     /**
18      * Returns the foo.
19      * @return String
20      */

21     public String JavaDoc getFoo() {
22         return foo;
23     }
24
25     /**
26      * Sets the bar.
27      * @param bar The bar to set
28      */

29     public void setBar(String JavaDoc bar) {
30         this.bar = bar;
31     }
32
33     /**
34      * Sets the foo.
35      * @param foo The foo to set
36      */

37     public void setFoo(String JavaDoc foo) {
38         this.foo = foo;
39     }
40
41     /**
42      * @see java.lang.Comparable#compareTo(java.lang.Object)
43      */

44     public int compareTo(Object JavaDoc 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 JavaDoc that) {
53         CompositeElement ce = (CompositeElement) that;
54         return ce.bar.equals(bar) && ce.foo.equals(foo);
55     }
56
57 }
58
Popular Tags