View Javadoc
1   package org.pojomatic.diff;
2   
3   import org.pojomatic.Pojomatic;
4   import org.pojomatic.annotations.Property;
5   
6   public class ValueDifference implements Difference {
7     @Property
8     private final String propertyName;
9   
10    @Property
11    private final Object leftValue;
12  
13    @Property
14    private final Object rightValue;
15  
16    public ValueDifference(String propertyName, Object lhs, Object rhs) {
17      this.propertyName = propertyName;
18      this.leftValue = lhs;
19      this.rightValue = rhs;
20    }
21  
22    @Override
23    public String propertyName() {
24      return propertyName;
25    }
26  
27    @Override
28    public Object leftValue() {
29      return leftValue;
30    }
31  
32    @Override
33    public Object rightValue() {
34      return rightValue;
35    }
36  
37    @Override
38    public boolean equals(Object obj) {
39      return Pojomatic.equals(this, obj);
40    }
41  
42    @Override
43    public int hashCode() {
44      return Pojomatic.hashCode(this);
45    }
46  
47    @Override
48    public String toString() {
49      //TODO - can we do better here?
50      return propertyName + ": {" + leftValue + "} versus {" + rightValue + "}";
51    }
52  
53  }