The Spring Expression Language (SpEL) is a simple and powerful expression language
which helps to query and manipulate objects at runtime.
The following example shows using first matching selection operator (^[selectionExpression]).
It filters the collection and returns the first element matching given selection criteria.
/**
* First matching Employee having salary greater than 4000
*/
ExpressionParser parser = new SpelExpressionParser();
Employee emp = (Employee) parser.parseExpression(
"#emps.^[salary > 4000]").getValue(stdContext);
System.out.println(emp);
/**
* First matching Employee having salary less than 4000
*/
emp = (Employee) parser.parseExpression(
"#emps.^[salary < 4000]").getValue(stdContext);
System.out.println(emp);
}