Browse Source

make NE and IS filters work on multi-level paths

pull/16/head
Jochen Berger 12 years ago
parent
commit
1253f4aa21
  1. 40
      json-path/src/main/java/com/jayway/jsonpath/Criteria.java

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

@ -185,14 +185,21 @@ public class Criteria {
}); });
} else if (CriteriaType.NE.equals(key)) { } else if (CriteriaType.NE.equals(key)) {
if (expectedVal == null && actualVal == null) {
return false; return objectOrAnyCollectionItemMatches(actualVal, new Predicate<Object>() {
}
if (expectedVal == null) { @Override
return true; public boolean accept(Object value) {
} else { if (expectedVal == null && value == null) {
return !expectedVal.equals(actualVal); return false;
} }
if (expectedVal == null) {
return true;
} else {
return !expectedVal.equals(value);
}
}
});
} else if (CriteriaType.IN.equals(key)) { } else if (CriteriaType.IN.equals(key)) {
@ -287,12 +294,17 @@ public class Criteria {
return true; return true;
} else { } else {
Object actualVal = readSafely(this.key, map); Object actualVal = readSafely(this.key, map);
return objectOrAnyCollectionItemMatches(actualVal, new Predicate<Object>() {
if (isValue == null) { @Override
return actualVal == null; public boolean accept(Object value) {
} else { if (isValue == null) {
return isValue.equals(actualVal); return value == null;
} } else {
return isValue.equals(value);
}
}
});
} }
} else { } else {

Loading…
Cancel
Save