Skip to content

Commit 7c096c6

Browse files
Duncan MackinderDuncan Mackinder
authored andcommitted
Restore and deprecate Customization matches
Restore original Customization matches(Object actual, Object expected) method, but mark it deprecated. This method is normally only called from CustomComparator compareValues method, which now calls the new Customization matches(String prefix, Object actual, Object expected, JSONCompareResult result) method. Add JavaDoc to Customization matches methods
1 parent 7928d10 commit 7c096c6

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

src/main/java/org/skyscreamer/jsonassert/Customization.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,47 @@ public boolean appliesToPath(String path) {
2222
return this.path.equals(path);
2323
}
2424

25+
/**
26+
* Return true if actual value matches expected value using this
27+
* Customization's comparator. Calls to this method should be replaced by
28+
* calls to matches(String prefix, Object actual, Object expected,
29+
* JSONCompareResult result).
30+
*
31+
* @param actual
32+
* JSON value being tested
33+
* @param expected
34+
* expected JSON value
35+
* @return true if actual value matches expected value
36+
*/
37+
@Deprecated
38+
public boolean matches(Object actual, Object expected) {
39+
return comparator.equal(actual, expected);
40+
}
41+
42+
/**
43+
* Return true if actual value matches expected value using this
44+
* Customization's comparator. The equal method used for comparison depends
45+
* on type of comparator.
46+
*
47+
* @param prefix
48+
* JSON path of the JSON item being tested (only used if
49+
* comparator is a LocationAwareValueMatcher)
50+
* @param actual
51+
* JSON value being tested
52+
* @param expected
53+
* expected JSON value
54+
* @param result
55+
* JSONCompareResult to which match failure may be passed (only
56+
* used if comparator is a LocationAwareValueMatcher)
57+
* @return true if expected and actual equal or any difference has already
58+
* been passed to specified result instance, false otherwise.
59+
* @throws ValueMatcherException
60+
* if expected and actual values not equal and ValueMatcher
61+
* needs to override default comparison failure message that
62+
* would be generated if this method returned false.
63+
*/
2564
public boolean matches(String prefix, Object actual, Object expected,
26-
JSONCompareResult result) {
65+
JSONCompareResult result) throws ValueMatcherException {
2766
if (comparator instanceof LocationAwareValueMatcher) {
2867
return ((LocationAwareValueMatcher<Object>)comparator).equal(prefix, actual, expected, result);
2968
}

0 commit comments

Comments
 (0)