title: If not null - java 8 style
body: <p>Java 8 presents <code>Optional</code> class.</p>
  
  <p>Before (Java 7):</p>
  
  <pre><code>Order order = orderBean.getOrder(id);
  if (order != null) {
      order.setStatus(true);
      pm.persist(order);
  } else {
      logger.warning("Order is null");
  }
  </code></pre>
  
  <p>So on Java 8 style:</p>
  
  <pre><code>Optional&lt;Order&gt; optional = Optional.ofNullable(orderBean.getOrder(id));
  optional.ifPresent( s -&gt; {
      s.setStatus(true);
      pm.persist(s);
      //Can we return from method in this place (not from lambda) ???
  });
  //So if return take place above, we can avoid if (!optional.isPresent) check
  if (!optional.isPresent) {
      logger.warning("Order is null");
  } 
  </code></pre>
  
  <p>Is it correct to use <code>Optional</code> in this case? Can anyone propose a more convenient way in Java 8 style?</p>