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 last matching selection operator ($[selectionExpression]).
It filters the collection and returns the last element matching given selection criteria.
/**
* Last 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);
/**
* Last matching Employee having salary less than 4000
*/
emp = (Employee) parser.parseExpression(
"#emps.$[salary < 4000]").getValue(stdContext);
System.out.println(emp);
}