I'd like to do something like this:
{ param -> if ( <condition over param> ) process ( param ) } ( provider () );
i.e., param is a value returned by a method (which, let's say, takes a long time to run, so I want to invoke it once only) and I want to pass on such value only if it fulfils a condition.
The alternative would be:
Param param = provider(); if ( <cond> ) process ( param );
But the lambda-based version, if I could make it working, would be shorter. The code above doesn't compile in Java and I cannot figure out if what I'm thinking about is possible and how.
""is never equal to an instance ofParam. Further,processseems to take a parameter in one variant, but no parameters in the other…