Browse Source

Merge pull request #43 from jochenberger/criteria-fixes

small fixes for the Criteria class
pull/44/head
kallestenflo 10 years ago
parent
commit
5136b4099b
  1. 32
      json-path/src/main/java/com/jayway/jsonpath/Criteria.java

32
json-path/src/main/java/com/jayway/jsonpath/Criteria.java

@ -29,7 +29,7 @@ public class Criteria implements Predicate {
private final List<Criteria> criteriaChain; private final List<Criteria> criteriaChain;
private enum CriteriaType { private static enum CriteriaType {
EQ { EQ {
@Override @Override
boolean eval(Object expected, Object actual, Configuration configuration) { boolean eval(Object expected, Object actual, Configuration configuration) {
@ -329,7 +329,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria is(Object o) { public Criteria is(Object o) {
this.criteriaType = CriteriaType.TYPE.EQ; this.criteriaType = CriteriaType.EQ;
this.expected = o; this.expected = o;
return this; return this;
} }
@ -351,7 +351,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria ne(Object o) { public Criteria ne(Object o) {
this.criteriaType = CriteriaType.TYPE.NE; this.criteriaType = CriteriaType.NE;
this.expected = o; this.expected = o;
return this; return this;
} }
@ -363,7 +363,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria lt(Object o) { public Criteria lt(Object o) {
this.criteriaType = CriteriaType.TYPE.LT; this.criteriaType = CriteriaType.LT;
this.expected = o; this.expected = o;
return this; return this;
} }
@ -375,7 +375,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria lte(Object o) { public Criteria lte(Object o) {
this.criteriaType = CriteriaType.TYPE.LTE; this.criteriaType = CriteriaType.LTE;
this.expected = o; this.expected = o;
return this; return this;
} }
@ -387,7 +387,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria gt(Object o) { public Criteria gt(Object o) {
this.criteriaType = CriteriaType.TYPE.GT; this.criteriaType = CriteriaType.GT;
this.expected = o; this.expected = o;
return this; return this;
} }
@ -399,7 +399,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria gte(Object o) { public Criteria gte(Object o) {
this.criteriaType = CriteriaType.TYPE.GTE; this.criteriaType = CriteriaType.GTE;
this.expected = o; this.expected = o;
return this; return this;
} }
@ -412,7 +412,7 @@ public class Criteria implements Predicate {
*/ */
public Criteria regex(Pattern pattern) { public Criteria regex(Pattern pattern) {
notNull(pattern, "pattern can not be null"); notNull(pattern, "pattern can not be null");
this.criteriaType = CriteriaType.TYPE.REGEX; this.criteriaType = CriteriaType.REGEX;
this.expected = pattern; this.expected = pattern;
return this; return this;
} }
@ -437,7 +437,7 @@ public class Criteria implements Predicate {
*/ */
public Criteria in(Collection<?> c) { public Criteria in(Collection<?> c) {
notNull(c, "collection can not be null"); notNull(c, "collection can not be null");
this.criteriaType = CriteriaType.TYPE.IN; this.criteriaType = CriteriaType.IN;
this.expected = c; this.expected = c;
return this; return this;
} }
@ -462,7 +462,7 @@ public class Criteria implements Predicate {
*/ */
public Criteria nin(Collection<?> c) { public Criteria nin(Collection<?> c) {
notNull(c, "collection can not be null"); notNull(c, "collection can not be null");
this.criteriaType = CriteriaType.TYPE.NIN; this.criteriaType = CriteriaType.NIN;
this.expected = c; this.expected = c;
return this; return this;
} }
@ -487,7 +487,7 @@ public class Criteria implements Predicate {
*/ */
public Criteria all(Collection<?> c) { public Criteria all(Collection<?> c) {
notNull(c, "collection can not be null"); notNull(c, "collection can not be null");
this.criteriaType = CriteriaType.TYPE.ALL; this.criteriaType = CriteriaType.ALL;
this.expected = c; this.expected = c;
return this; return this;
} }
@ -504,7 +504,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria size(int size) { public Criteria size(int size) {
this.criteriaType = CriteriaType.TYPE.SIZE; this.criteriaType = CriteriaType.SIZE;
this.expected = size; this.expected = size;
return this; return this;
} }
@ -517,7 +517,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria exists(boolean b) { public Criteria exists(boolean b) {
this.criteriaType = CriteriaType.TYPE.EXISTS; this.criteriaType = CriteriaType.EXISTS;
this.expected = b; this.expected = b;
return this; return this;
} }
@ -530,7 +530,7 @@ public class Criteria implements Predicate {
*/ */
public Criteria type(Class<?> t) { public Criteria type(Class<?> t) {
notNull(t, "type can not be null"); notNull(t, "type can not be null");
this.criteriaType = CriteriaType.TYPE.TYPE; this.criteriaType = CriteriaType.TYPE;
this.expected = t; this.expected = t;
return this; return this;
} }
@ -541,7 +541,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria notEmpty() { public Criteria notEmpty() {
this.criteriaType = CriteriaType.TYPE.NOT_EMPTY; this.criteriaType = CriteriaType.NOT_EMPTY;
this.expected = null; this.expected = null;
return this; return this;
} }
@ -552,7 +552,7 @@ public class Criteria implements Predicate {
* @return * @return
*/ */
public Criteria matches(Predicate p) { public Criteria matches(Predicate p) {
this.criteriaType = CriteriaType.TYPE.MATCHES; this.criteriaType = CriteriaType.MATCHES;
this.expected = p; this.expected = p;
return this; return this;
} }

Loading…
Cancel
Save