Skip to content

Commit 227538f

Browse files
committed
Cover all extensible/strict ordering permutations
1 parent 724a67c commit 227538f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,28 @@ public boolean hasStrictOrder() {
7474
}
7575

7676
/**
77-
* @return the non-strict equivalent.
77+
* Get the equivalent {@code JSONCompareMode} with or without strict ordering.
78+
*
79+
* @return the equivalent {@code JSONCompareMode}
7880
*/
79-
public JSONCompareMode butNotStrict() {
80-
return isExtensible() ? LENIENT : NON_EXTENSIBLE;
81+
public JSONCompareMode withStrictOrdering(boolean strictOrdering) {
82+
if (strictOrdering) {
83+
return isExtensible() ? STRICT_ORDER : STRICT;
84+
} else {
85+
return isExtensible() ? LENIENT : NON_EXTENSIBLE;
86+
}
8187
}
8288

8389
/**
84-
* @return the extensible equivalent.
90+
* Get the equivalent {@code JSONCompareMode} with or without extensibility.
91+
*
92+
* @return the equivalent {@code JSONCompareMode}
8593
*/
86-
public JSONCompareMode withExtensibility() {
87-
return hasStrictOrder() ? STRICT_ORDER : LENIENT;
94+
public JSONCompareMode withExtensible(boolean extensible) {
95+
if (extensible) {
96+
return hasStrictOrder() ? STRICT_ORDER : LENIENT;
97+
} else {
98+
return hasStrictOrder() ? STRICT : NON_EXTENSIBLE;
99+
}
88100
}
89101
}

0 commit comments

Comments
 (0)