title: Convert if else statement in Optional.ofNullable().ifPresent() in Java
body: <p>I have this statement in java </p>
  
  <pre><code>if (payload.get("mimeType") != null) {
      lettersPayload.put("mimeType", payload.get("mimeType"));
  
      if (!StringUtils.isEmpty(heytype) &amp;&amp; !"all".equals(type)) {
          lettersPayload.put("heytype", heytype);
      }
  }
  </code></pre>
  
  <p>I have a requirment to do this code snippet with <code>Optional.ofNullable().ifPresent()</code>
  I wrote these:</p>
  
  <pre><code>Optional.of(payload.get("mimeType")).ifPresent(name -&gt; lettersPayload.put("heytype", heytype));
  </code></pre>
  
  <p>The second statement is crushing</p>
  
  <p>Any ideas?
  Thanks!</p>