First of all, please consider I am beginner as a developer and as a Spring user too. I am searching for a solution to this problem:
There is a given list filled with JsonNode objects, called attributes. I have to find which one is evaulating true against a given boolean expression. I would like to register a collection in a context, iterating over it and finding if any attributes evaulate true with SpEl, so I don't have to make this quite expensive context creation every time.
Do you have any idea how to do it faster? (The code is dummy. Problem is real.)
//given
List<JsonNode> attributes;
attributes
.stream()
.anyMatch(attribute -> {
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("attribute.name == 'John Doe'");
EvaluationContext ctx = new StandardEvaluationContext(attribute);
return exp.getValue(ctx, Boolean.class);
});
Thank you for your help!