KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > diff > MockDifference


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.util.diff;
5
6 import org.apache.commons.lang.builder.EqualsBuilder;
7
8 /**
9  * A mock {@link Difference}, for use in tests.
10  */

11 public class MockDifference extends Difference {
12
13   private final Object JavaDoc a;
14   private final Object JavaDoc b;
15
16   public MockDifference(DifferenceContext where, Object JavaDoc a, Object JavaDoc b) {
17     super(where);
18
19     this.a = a;
20     this.b = b;
21   }
22
23   public MockDifference(DifferenceContext where) {
24     this(where, new Object JavaDoc(), new Object JavaDoc());
25   }
26
27   public Object JavaDoc a() {
28     return this.a;
29   }
30
31   public Object JavaDoc b() {
32     return this.b;
33   }
34
35   public String JavaDoc toString() {
36     return "<MockDifference: " + a() + ", " + b() + ">";
37   }
38
39   public boolean equals(Object JavaDoc that) {
40     if (!(that instanceof MockDifference)) return false;
41
42     MockDifference mockThat = (MockDifference) that;
43
44     return new EqualsBuilder().appendSuper(super.equals(that)).append(this.a, mockThat.a).append(this.b, mockThat.b)
45         .isEquals();
46   }
47
48 }
Popular Tags