title: java 8: Using Optional with lambda
body: <p><strong>How can I code the logic below using Optional and lambda?</strong>
  I have two Lists</p>
  
  <blockquote>
    <p>List success = new ArrayList&lt;>();
    <br> 
    List failures = new ArrayList&lt;>();</p>
  </blockquote>
  
  <p>And there is an object </p>
  
  <blockquote>
    <p>RoomTypes value</p>
  </blockquote>
  
  <p>for which <code>value.getErrorType()</code> could be NULL or not and <code>value.getId()</code> returns integer.</p>
  
  <p>I would like to update <code>success</code> and <code>failure</code> with <code>value.getId()</code> list according to <code>value.getErrorType()</code> being null.</p>
  
  <p>Something like:</p>
  
  <pre><code>if(value.getErrorType().equals(NULL)){
     success.add(value.getId())
  }
  else{
     failure.add(value.getId())
  }
  </code></pre>