title: JAVA 8 Optional map or else
body: <p>Hello I've written statement with <code>Optional&lt;Parameter&gt;</code> and i return <em>true</em> if <strong>Parameter</strong> is present and it's value is <em>false</em>.</p>
  
  <pre><code>public boolean getNoDailyAllowance(String code) {
      Optional&lt;Parameter&gt; myParam = parameterDao.getCachedParameter(code);
      return myParam.isPresent() &amp;&amp; !myParam.get().currentValueBoolean();
  }
  </code></pre>
  
  <p>I want to rewrite it something like this </p>
  
  <pre><code>return calcDailyAllowanceParam.map(parameter -&gt; Boolean.parseBoolean(parameter.getCurrentValue())).orElse(false); 
  </code></pre>
  
  <p>but i can't add <strong>!</strong> operator before <code>parameter.getCurrentValue()</code> what i do incorrectly.</p>