| 1 | |
package uk.co.datumedge.hamcrest.json; |
| 2 | |
|
| 3 | |
import static org.skyscreamer.jsonassert.JSONCompare.compareJSON; |
| 4 | |
import static uk.co.datumedge.hamcrest.json.JSONAssertComparisonResult.resultOf; |
| 5 | |
|
| 6 | |
import org.json.JSONException; |
| 7 | |
import org.json.JSONObject; |
| 8 | |
import org.skyscreamer.jsonassert.JSONCompareMode; |
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
final class JSONObjectComparatorFactory implements JSONAssertComparatorFactory<JSONObject> { |
| 14 | 1 | private static final JSONAssertComparatorFactory<JSONObject> INSTANCE = new JSONObjectComparatorFactory(); |
| 15 | |
|
| 16 | |
static JSONAssertComparatorFactory<JSONObject> jsonObjectComparison() { |
| 17 | 7 | return INSTANCE; |
| 18 | |
} |
| 19 | |
|
| 20 | 1 | private JSONObjectComparatorFactory() { } |
| 21 | |
|
| 22 | |
@Override |
| 23 | |
public JSONComparator<JSONObject> comparatorWith(final JSONCompareMode compareMode) { |
| 24 | 14 | return new JSONComparator<JSONObject>() { |
| 25 | |
@Override |
| 26 | |
public JSONComparisonResult compare(JSONObject expected, JSONObject actual) throws JSONException { |
| 27 | 7 | return resultOf(compareJSON(expected, actual, compareMode)); |
| 28 | |
} |
| 29 | |
}; |
| 30 | |
} |
| 31 | |
} |