views:

77

answers:

1

I can't see any way to build a Predicate that uses parenthesis to control logical order. Is there one?

Say I want to do something like Predicate <= mumble and (foo or baz)

A simple Predicates.and or a Predicates.or has no equivalent that says "foo or baz" and with mumble.

Is this possible?

+5  A: 

It just depends on how you construct it:

// (mumble and foo) or baz
Predicates.or(Predicates.and(mumble, foo), baz)

// mumble and (foo or baz)
Predicates.and(mumble, Predicates.or(foo, baz))

There's no real need for "parentheses" because it's unambiguous from the method calls themselves.

Jon Skeet
Thanks,Predicates.and(mumble, Predicates.of(foo, baz))is what I want.
fishtoprecords
To help future readers, accept this answer by clicking the hollow check mark on the left. This way, future readers know at a glance that this answer helped you.
Wesley
There is a typo in the last statement. Should be `or` instead of `of`.
Willi
@Willi: Thanks, fixed.
Jon Skeet