title: Java Optional.ifPresentOrElse with return value
body: <p>In Java, I have recently began to adopt the <code>Optional</code> type more in my code. This allows for better <code>null</code>-value handling and to some extend also safer code. <code>Optional</code> has the <code>ifPresentOrElse</code> method which allows you to perform a specific action for when a value is present, or a specific action for when no value is present. However, this method does not allow you to declare a return type. </p>
  
  <p>Is there an easy way I can use optionals and a <code>ifPresentOrElse</code>-like method to return values while unwrapping an <code>Optional</code>?</p>