title: Throw an exception if an Optional<> is present
body: <p>Let's say I want to see if an object exists in a stream and if it is not present, throw an Exception. One way I could do that would be using the <code>orElseThrow</code> method:</p>
  
  <pre><code>List&lt;String&gt; values = new ArrayList&lt;&gt;();
  values.add("one");
  //values.add("two");  // exception thrown
  values.add("three");
  String two = values.stream()
          .filter(s -&gt; s.equals("two"))
          .findAny()
          .orElseThrow(() -&gt; new RuntimeException("not found"));
  </code></pre>
  
  <p>What about in the reverse? If I want to throw an exception if any match is found:</p>
  
  <pre><code>String two = values.stream()
          .filter(s -&gt; s.equals("two"))
          .findAny()
          .ifPresentThrow(() -&gt; new RuntimeException("not found"));
  </code></pre>
  
  <p>I could just store the <code>Optional</code>, and do the <code>isPresent</code> check after:</p>
  
  <pre><code>Optional&lt;String&gt; two = values.stream()
          .filter(s -&gt; s.equals("two"))
          .findAny();
  if (two.isPresent()) {
      throw new RuntimeException("not found");
  }
  </code></pre>
  
  <p>Is there any way to achieve this <code>ifPresentThrow</code> sort of behavior? Is trying to do throw in this way a bad practice?</p>