title: How to define and invoke inline a lambda expression in Java
body: <p>I'd like to do something like this: </p>
  
  <pre><code>{ param -&gt; if ( &lt;condition over param&gt; ) process ( param ) } ( provider () );
  </code></pre>
  
  <p>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.</p>
  
  <p>The alternative would be:</p>
  
  <pre><code>Param param = provider(); if ( &lt;cond&gt; ) process ( param );
  </code></pre>
  
  <p>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.</p>