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 private static final JSONComparisonResult PASSED = new JSONComparisonResult();
11 private final boolean passed;
12 private final SelfDescribing description;
13
14 private JSONComparisonResult() {
15 this.passed = true;
16 this.description = new SelfDescribing() {
17 @Override public void describeTo(Description description) { }
18 };
19 }
20
21 public JSONComparisonResult(SelfDescribing description) {
22 this.passed = false;
23 this.description = description;
24 }
25
26 @Override
27 public void describeTo(Description description) {
28 description.appendDescriptionOf(this.description);
29 }
30
31 public boolean failed() {
32 return !passed;
33 }
34
35 public boolean passed() {
36 return passed;
37 }
38
39 static JSONComparisonResult comparisonPassed() {
40 return PASSED;
41 }
42 }