@Override public FilterExpression visitNotExpression(NotFilterExpression fe) { FilterExpression inner = fe.getNegated(); if (inner instanceof AndFilterExpression) { AndFilterExpression and = (AndFilterExpression) inner; FilterExpression left = new NotFilterExpression(and.getLeft()).accept(this); FilterExpression right = new NotFilterExpression(and.getRight()).accept(this); return new OrFilterExpression(left, right); } if (inner instanceof OrFilterExpression) { OrFilterExpression or = (OrFilterExpression) inner; FilterExpression left = new NotFilterExpression(or.getLeft()).accept(this); FilterExpression right = new NotFilterExpression(or.getRight()).accept(this); return new AndFilterExpression(left, right); } if (inner instanceof NotFilterExpression) { NotFilterExpression not = (NotFilterExpression) inner; return (not.getNegated()).accept(this); } if (inner instanceof FilterPredicate) { FilterPredicate filter = (FilterPredicate) inner; return filter.negate(); } return inner; } }
@Override public FilterExpression visitNotExpression(NotFilterExpression fe) { FilterExpression inner = fe.getNegated(); if (inner instanceof AndFilterExpression) { AndFilterExpression and = (AndFilterExpression) inner; FilterExpression left = new NotFilterExpression(and.getLeft()).accept(this); FilterExpression right = new NotFilterExpression(and.getRight()).accept(this); return new OrFilterExpression(left, right); } if (inner instanceof OrFilterExpression) { OrFilterExpression or = (OrFilterExpression) inner; FilterExpression left = new NotFilterExpression(or.getLeft()).accept(this); FilterExpression right = new NotFilterExpression(or.getRight()).accept(this); return new AndFilterExpression(left, right); } if (inner instanceof NotFilterExpression) { NotFilterExpression not = (NotFilterExpression) inner; return (not.getNegated()).accept(this); } if (inner instanceof FilterPredicate) { FilterPredicate filter = (FilterPredicate) inner; return filter.negate(); } return inner; } }