/** * Retrieves the subject(lhs expression) which could be an array * or string, the search(rhs expression) which could be any JmesPath * expression. If subject is an array, this function returns true if * one of the elements in the array is equal to the provided search * value. If the provided subject is a string, this function returns * true if the string contains the provided search argument. * * @param evaluatedArgs List of input expressions * @return True subject contains search; * False otherwise */ @Override public JsonNode evaluate(List<JsonNode> evaluatedArgs) { JsonNode subject = evaluatedArgs.get(0); JsonNode search = evaluatedArgs.get(1); if (subject.isArray()) { return doesArrayContain(subject, search); } else if (subject.isTextual()) { return doesStringContain(subject, search); } throw new InvalidTypeException("Type mismatch. Expecting a string or an array."); }
private static JmesPathExpression jsonToFunctionExpression(JsonNode jsonNode) { List<JmesPathExpression> args = getChildren(jsonNode); switch (jsonNode.get("value").asText()){ case "length": return new JmesPathLengthFunction(args); case "contains": return new JmesPathContainsFunction(args); } return null; }
/** * Retrieves the subject(lhs expression) which could be an array * or string, the search(rhs expression) which could be any JmesPath * expression. If subject is an array, this function returns true if * one of the elements in the array is equal to the provided search * value. If the provided subject is a string, this function returns * true if the string contains the provided search argument. * * @param evaluatedArgs List of input expressions * @return True subject contains search; * False otherwise */ @Override public JsonNode evaluate(List<JsonNode> evaluatedArgs) { JsonNode subject = evaluatedArgs.get(0); JsonNode search = evaluatedArgs.get(1); if (subject.isArray()) { return doesArrayContain(subject, search); } else if (subject.isTextual()) { return doesStringContain(subject, search); } throw new InvalidTypeException("Type mismatch. Expecting a string or an array."); }
private static JmesPathExpression jsonToFunctionExpression(JsonNode jsonNode) { List<JmesPathExpression> args = getChildren(jsonNode); switch (jsonNode.get("value").asText()){ case "length": return new JmesPathLengthFunction(args); case "contains": return new JmesPathContainsFunction(args); } return null; }
/** * Retrieves the subject(lhs expression) which could be an array * or string, the search(rhs expression) which could be any JmesPath * expression. If subject is an array, this function returns true if * one of the elements in the array is equal to the provided search * value. If the provided subject is a string, this function returns * true if the string contains the provided search argument. * * @param evaluatedArgs List of input expressions * @return True subject contains search; * False otherwise */ @Override public JsonNode evaluate(List<JsonNode> evaluatedArgs) { JsonNode subject = evaluatedArgs.get(0); JsonNode search = evaluatedArgs.get(1); if (subject.isArray()) { return doesArrayContain(subject, search); } else if (subject.isTextual()) { return doesStringContain(subject, search); } throw new InvalidTypeException("Type mismatch. Expecting a string or an array."); }