/** * Guards the filter against potential null values in the target property name (if it is a * property name, to start with) */ private Filter guardAgainstNulls(Filter filter, Expression potentialPropertyName) { if (potentialPropertyName instanceof PropertyName) { PropertyName pn = (PropertyName) potentialPropertyName; String name = pn.getPropertyName(); if (isNillable(name)) { Not notNull = ff.not(ff.isNull(ff.property(name))); if (filter instanceof And) { And and = (And) filter; List<Filter> children = new ArrayList<Filter>(and.getChildren()); children.add(notNull); return ff.and(children); } else { return ff.and(filter, notNull); } } } return filter; }