title: Java 8 optional: ifPresent return object orElseThrow exception
body: <p>I'm trying to make something like this:</p>
  
  <pre><code> private String getStringIfObjectIsPresent(Optional&lt;Object&gt; object){
          object.ifPresent(() -&gt;{
              String result = "result";
              //some logic with result and return it
              return result;
          }).orElseThrow(MyCustomException::new);
      }
  </code></pre>
  
  <p>This won't work, because ifPresent takes Consumer functional interface as parameter, which has void accept(T t). It cannot return any value. Is there any other way to do it ?</p>