KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junitx > extensions > Foo


1 package junitx.extensions;
2
3 import java.io.Serializable JavaDoc;
4
5 /**
6  * Contrived class used in testing the abstract interface functional
7  * compliance tests.
8  *
9  * @version $Revision: 1.1 $ $Date: 2003/02/05 10:27:29 $
10  * @author <a HREF="mailto:pholser@yahoo.com">Paul Holser</a>
11  */

12 public final class Foo
13         implements Serializable JavaDoc, Comparable JavaDoc {
14
15     private int i;
16
17     public Foo(int i) {
18         this.i = i;
19     }
20
21     public boolean equals(Object JavaDoc that) {
22         return (that instanceof Foo) && ((Foo) that).i == i;
23     }
24
25     public int hashCode() {
26         int result = 17;
27
28         result = 37 * result + i;
29
30         return result;
31     }
32
33     public int compareTo(Object JavaDoc that) {
34         Foo other = (Foo) that;
35         return i - other.i;
36     }
37
38     public String JavaDoc toString() {
39         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("Foo[i=");
40         buffer.append(i);
41         buffer.append(']');
42
43         return buffer.toString();
44     }
45
46     public int getI() {
47         return i;
48     }
49 }
50
Popular Tags