From c9527bf89e5c314b19b9c6c16d3bcab8e0926b08 Mon Sep 17 00:00:00 2001 From: Daniel Halperin Date: Wed, 28 Jun 2017 10:15:54 -0700 Subject: [PATCH] Rename subset to subsetof --- README.md | 2 +- .../src/main/java/com/jayway/jsonpath/Criteria.java | 12 ++++++------ .../jsonpath/internal/filter/EvaluatorFactory.java | 6 +++--- .../jsonpath/internal/filter/RelationalOperator.java | 2 +- .../jayway/jsonpath/internal/filter/ValueNode.java | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index bf7050641..5efe798cd 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/json-path/src/main/java/com/jayway/jsonpath/Criteria.java b/json-path/src/main/java/com/jayway/jsonpath/Criteria.java index 789b2a83a..92f9b2bca 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/Criteria.java +++ b/json-path/src/main/java/com/jayway/jsonpath/Criteria.java @@ -268,28 +268,28 @@ public Criteria nin(Collection c) { } /** - * The subset operator selects objects for which the specified field is + * The subsetof 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 subset operator selects objects for which the specified field is + * The subsetof 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; } diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/EvaluatorFactory.java b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/EvaluatorFactory.java index 2491a1597..ac47274a7 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/EvaluatorFactory.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/EvaluatorFactory.java @@ -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){ @@ -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; @@ -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); } } diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/RelationalOperator.java b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/RelationalOperator.java index d8ff484c9..830cc3bb3 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/RelationalOperator.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/RelationalOperator.java @@ -30,7 +30,7 @@ public enum RelationalOperator { TYPE("TYPE"), MATCHES("MATCHES"), EMPTY("EMPTY"), - SUBSET("SUBSET"); + SUBSETOF("SUBSETOF"); private final String operatorString; diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java index 9aac34a45..308a453ac 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java @@ -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;