We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi just wondering if there's a way to query an array list short of iterating through all and flagging something?
I wanted to check if ALL objects in an array list had a flag set to true.. kind of like a reduce map or in C# .Any query?
Answers
Although PDE is using Java 8, the way it is currently set up, latest functional syntaxes aren't allowed! =((
We'd need to write them on some other IDE for it. Otherwise we'd be allowed to use Collection::stream() & invoke Stream::allMatch() passing a Predicate as its argument using Java 8's lambda thin arrow operator
->
: :-<Anyways, here's some archaic Java mock approach for it: :(|)
But in the end, I've managed to use Stream::allMatch(), by instantiating my own Predicate & implementing its
abstract
method test(). \m/However, it's not as good as an actual lambda
->
expression, which isn't bound to a specific datatype, escaping somehow from Java's brutal strongly typed system. O:-)Another approach, besides using another IDE for a full Java 8 syntax, is implementing a function under Java's builtin JS language called Nashorn, and invoking it from Java's side, passing your Collection container as its argument. :ar!
After all in JS, all of its functions act like lambdas. And they can be passed freely as argument for another function, becoming callbacks for the receiving function! :-bd