title: Convenient way of checking equality for Optionals
body: <p>I'm looking for a more convenient way of proofing equality for an Optional value.</p>
  
  <p>This is what an <a href="http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html" rel="noreferrer">Oracle Blog post</a> suggests:</p>
  
  <pre><code>Optional&lt;USB&gt; maybeUSB = ...; maybeUSB.filter(usb -&gt; "3.0".equals(usb.getVersion())
                      .ifPresent(() -&gt; System.out.println("ok"));
  </code></pre>
  
  <p>IMHO results in something like</p>
  
  <pre><code>if (maybeUSB.filter(c -&gt; "3.0".equals(c.getVersion())).isPresent()) {
     ...
  }
  </code></pre>
  
  <p>Of course that's kind of a poor example because it compares the Version and not the instance of USB itself but I think it should still proof my point.</p>
  
  <p>Is this really as good as it gets?</p>
  
  <p>No</p>
  
  <pre><code>boolean presentAndEquals(Object)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>boolean deepEquals(Object)
  </code></pre>
  
  <p>Am I missing something here?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I'm not that happy with Optionals.equals either.
  Do I really have to box an Object first to instantly unbox and check for equality ?</p>
  
  <p><strong>EDIT II:</strong></p>
  
  <p>Pretty damn happy with:</p>
  
  <pre><code>optional
      .filter(nonOptional::equals)
      .isPresent()
  </code></pre>
  
  <p>nowadays.</p>
  
  <p>After some years of functional programming, <code>if</code> looses a <strong>lot</strong> of relevance.</p>