I have the following code using spring expression language:
StandardEvaluationContext stdContext = new StandardEvaluationContext();
stdContext.setVariable("emp", filterInputData);
ExpressionParser parser = new SpelExpressionParser();
parser.parseExpression("#emp.?[name.toLowerCase().contains('Hari')]").getValue(stdContext);
where emp is the name of the bean. Here the name can be null and when calling name.toLowerCase() I am getting a nullpointer exception. How to handle the null values in this scenario? I need to call toLowercase() for only non-null values.
toLowerCase().contains('Hari')is alwaysfalse