1 | |
package uk.co.datumedge.hamcrest.json; |
2 | |
|
3 | |
import org.hamcrest.Description; |
4 | |
import org.hamcrest.SelfDescribing; |
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
public final class JSONComparisonResult implements SelfDescribing { |
10 | 1 | private static final JSONComparisonResult PASSED = new JSONComparisonResult(); |
11 | |
private final boolean passed; |
12 | |
private final SelfDescribing description; |
13 | |
|
14 | 1 | private JSONComparisonResult() { |
15 | 1 | this.passed = true; |
16 | 1 | this.description = new SelfDescribing() { |
17 | 0 | @Override public void describeTo(Description description) { } |
18 | |
}; |
19 | 1 | } |
20 | |
|
21 | 13 | public JSONComparisonResult(SelfDescribing description) { |
22 | 13 | this.passed = false; |
23 | 13 | this.description = description; |
24 | 13 | } |
25 | |
|
26 | |
@Override |
27 | |
public void describeTo(Description description) { |
28 | 3 | description.appendDescriptionOf(this.description); |
29 | 3 | } |
30 | |
|
31 | |
public boolean failed() { |
32 | 22 | return !passed; |
33 | |
} |
34 | |
|
35 | |
public boolean passed() { |
36 | 22 | return passed; |
37 | |
} |
38 | |
|
39 | |
static JSONComparisonResult comparisonPassed() { |
40 | 9 | return PASSED; |
41 | |
} |
42 | |
} |