|
1 |
| package com.agical.rmock.core.match.reference; |
|
2 |
| |
|
3 |
| import java.io.IOException; |
|
4 |
| |
|
5 |
| import com.agical.rmock.core.describe.ExpressionDescriber; |
|
6 |
| import com.agical.rmock.core.match.Reference; |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| public class ToStringReference implements Reference { |
|
16 |
| |
|
17 |
| private final Object object; |
|
18 |
| |
|
19 |
7257
| public ToStringReference(Object object) {
|
|
20 |
7257
| super();
|
|
21 |
7257
| this.object = object;
|
|
22 |
| } |
|
23 |
| |
|
24 |
688
| public Object getObject() {
|
|
25 |
688
| return object;
|
|
26 |
| } |
|
27 |
| |
|
28 |
16
| public void describeWith(ExpressionDescriber expressionDescriber) throws IOException {
|
|
29 |
16
| if(object != null) {
|
|
30 |
15
| expressionDescriber.describeReference("<"+object.toString()+">");
|
|
31 |
| } |
|
32 |
| else { |
|
33 |
1
| expressionDescriber.describeReference("<null>");
|
|
34 |
| } |
|
35 |
| } |
|
36 |
| |
|
37 |
605
| public boolean objectEquals(Object object) {
|
|
38 |
605
| if (this.object == null) {
|
|
39 |
36
| return object == null;
|
|
40 |
| } |
|
41 |
569
| return this.object.equals(object);
|
|
42 |
| } |
|
43 |
| |
|
44 |
53
| public int objectCompareTo(Object object) {
|
|
45 |
53
| if(this.object instanceof Comparable) {
|
|
46 |
52
| return ((Comparable)this.object).compareTo(object);
|
|
47 |
| } |
|
48 |
1
| return this.object.equals(object) ? 0 : this.object.hashCode() - object.hashCode();
|
|
49 |
| } |
|
50 |
| |
|
51 |
| |
|
52 |
| } |