Skip to content

Commit

Permalink
Rename subset to subsetof
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalperi committed Jun 28, 2017
1 parent 32adc12 commit c9527bf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Filters are logical expressions used to filter arrays. A typical filter would be
| =~ | left matches regular expression [?(@.name =~ /foo.*?/i)] |
| in | left exists in right [?(@.size in ['S', 'M'])] |
| nin | left does not exists in right |
| subset | left is a subset of right [?(@.sizes subset ['S', 'M', 'L'])] |
| subsetof | left is a subset of right [?(@.sizes subsetof ['S', 'M', 'L'])] |
| size | size of left (array or string) should match right |
| empty | left (array or string) should be empty |

Expand Down
12 changes: 6 additions & 6 deletions json-path/src/main/java/com/jayway/jsonpath/Criteria.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,28 @@ public Criteria nin(Collection<?> c) {
}

/**
* The <code>subset</code> operator selects objects for which the specified field is
* The <code>subsetof</code> operator selects objects for which the specified field is
* an array whose elements comprise a subset of the set comprised by the elements of
* the specified array.
*
* @param o the values to match against
* @return the criteria
*/
public Criteria subset(Object... o) {
return subset(Arrays.asList(o));
public Criteria subsetof(Object... o) {
return subsetof(Arrays.asList(o));
}

/**
* The <code>subset</code> operator selects objects for which the specified field is
* The <code>subsetof</code> operator selects objects for which the specified field is
* an array whose elements comprise a subset of the set comprised by the elements of
* the specified array.
*
* @param c the values to match against
* @return the criteria
*/
public Criteria subset(Collection<?> c) {
public Criteria subsetof(Collection<?> c) {
notNull(c, "collection can not be null");
this.criteriaType = RelationalOperator.SUBSET;
this.criteriaType = RelationalOperator.SUBSETOF;
this.right = new ValueNode.ValueListNode(c);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class EvaluatorFactory {
evaluators.put(RelationalOperator.CONTAINS, new ContainsEvaluator());
evaluators.put(RelationalOperator.MATCHES, new PredicateMatchEvaluator());
evaluators.put(RelationalOperator.TYPE, new TypeEvaluator());
evaluators.put(RelationalOperator.SUBSET, new SubsetEvaluator());
evaluators.put(RelationalOperator.SUBSETOF, new SubsetOfEvaluator());
}

public static Evaluator createEvaluator(RelationalOperator operator){
Expand Down Expand Up @@ -266,7 +266,7 @@ private String getInput(ValueNode valueNode) {
}
}

private static class SubsetEvaluator implements Evaluator {
private static class SubsetOfEvaluator implements Evaluator {
@Override
public boolean evaluate(ValueNode left, ValueNode right, Predicate.PredicateContext ctx) {
ValueNode.ValueListNode rightValueListNode;
Expand All @@ -291,7 +291,7 @@ public boolean evaluate(ValueNode left, ValueNode right, Predicate.PredicateCont
} else {
leftValueListNode = left.asValueListNode();
}
return leftValueListNode.subset(rightValueListNode);
return leftValueListNode.subsetof(rightValueListNode);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum RelationalOperator {
TYPE("TYPE"),
MATCHES("MATCHES"),
EMPTY("EMPTY"),
SUBSET("SUBSET");
SUBSETOF("SUBSETOF");

private final String operatorString;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public boolean contains(ValueNode node){
return nodes.contains(node);
}

public boolean subset(ValueListNode right) {
public boolean subsetof(ValueListNode right) {
for (ValueNode leftNode : nodes) {
if (!right.nodes.contains(leftNode)) {
return false;
Expand Down

0 comments on commit c9527bf

Please sign in to comment.