Java streams' filters use Predicate
s to allow or deny an element through the stream.
Thanks to .compose
or .andThen
the filter can be restricted.
Yet what if I wanted to have it more permissive according to some flags?
For example, I might want to have isAppleAllowed
and isPearAllowed
parametrically set by the user.
The use of .filter(f -> isAppleAllowed || isPearAllowed)
doesn't work, because if either is True, both are allowed.
What can I use to extend the filter more permissively?
Thanks in advance for any help.