1 package junitx.extensions; 2 3 import java.io.Serializable ; 4 5 12 public final class Foo 13 implements Serializable , Comparable { 14 15 private int i; 16 17 public Foo(int i) { 18 this.i = i; 19 } 20 21 public boolean equals(Object 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 that) { 34 Foo other = (Foo) that; 35 return i - other.i; 36 } 37 38 public String toString() { 39 StringBuffer buffer = new StringBuffer ("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 |