| 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.skyscreamer.jsonassert.JSONCompareMode; |
| 8 | |
|
| 9 | |
final class StringComparatorFactory implements JSONAssertComparatorFactory<String> { |
| 10 | 1 | private static final JSONAssertComparatorFactory<String> INSTANCE = new StringComparatorFactory(); |
| 11 | |
|
| 12 | |
static JSONAssertComparatorFactory<String> stringComparison() { |
| 13 | 4 | return INSTANCE; |
| 14 | |
} |
| 15 | |
|
| 16 | 1 | private StringComparatorFactory() { } |
| 17 | |
|
| 18 | |
@Override |
| 19 | |
public JSONComparator<String> comparatorWith(final JSONCompareMode compareMode) { |
| 20 | 6 | return new JSONComparator<String>() { |
| 21 | |
@Override |
| 22 | |
public JSONComparisonResult compare(String expected, String actual) throws JSONException { |
| 23 | 6 | return resultOf(compareJSON(expected, actual, compareMode)); |
| 24 | |
} |
| 25 | |
}; |
| 26 | |
} |
| 27 | |
} |