Preamble
For some rudimentary filtering of records, based on permissions, I'm creating a number of implementations of the same interface, each of which can provide filtering/constraints for building a query. The response of each implementation is AND-combined (anyOf) with some other condition, before all of these are OR-combined (allOf).
One of these implementations may return something like this: QComment.comment.author.eq(user). However, some of these implementations just want to express that the access is completely denied ("false") or allowed ("true").
This question is not about my business logic, that's why I glossed over it, but the point is that:
Question
I want to return a BooleanExpression that evaluates to false, resp. true.
I've come up with the following:
BooleanExpression FALSE_CLAUSE = Expressions.FALSE.ne(Expressions.FALSE);
BooleanExpression TRUE_CLAUSE = Expressions.TRUE.eq(Expressions.TRUE);
While this works quite well, it seems rather ugly. Is there a better way in Querydsl to do this? I was expecting BooleanExpression.FALSE and BooleanExpression.TRUE. Surprised not to find those.