Open gekoramy opened 3 years ago
Thanks a lot for your suggestion. I can see how this could help in your example, though it's not strictly necessary. You can always just filter(t -> t.v2 > 17)
.
These Function[N]
and Consumer[N]
types are the minimum required functional interfaces of degree N to model both value-compatible and void-compatible lambdas. A Predicate<T>
is just a Function<T, Boolean>
, and as such, wasn't added. The same is true for the equivalents of ToIntFunction
, ToLongFunction
, ToDoubleFunction
, and all the rest.
I would need a few more applications than this convenience to justify adding another 16 interfaces.
I see your point
What about an implementation that does not require any Predicate[N]
at all?
Predicate<Tuple0> Tuple.predicate(Function0<Boolean>)
Predicate<Tuple1<T1>> Tuple.predicate(Function1<T1, Boolean>)
Predicate<Tuple2<T1, T2>> Tuple.predicate(Function2<T1, T2, Boolean>)
...
Predicate<Tuple[N]<T...>> Tuple.predicate(Function[N]<T..., Boolean>)
I had thought of it. A Predicate
offers 2-valued booleans, a Function<?, Boolean>
technically supports 3-valued booleans (null
), so I'm not too happy with that workaround.
You are right
I didn't think about the null
value
After all, it must be for this reason that Java devs have introduced the Predicate<T>
interface
Well, we might get Function<?, boolean>
some time soon, in case of which that might indeed work.
I re-propose attention to an old issue that has not yet been fully solved: #214
Currently jOOL offers:
But it misses:
In order to beautify stream processing like that: