title: Java 8 - Stream, filter and optional
body: <p>I have the following code</p>
  
  <pre><code>public Player findPlayerByUsername(String username) {
      return players.stream().filter(p -&gt; p.getUsername().equalsIgnoreCase(username))
                    .findFirst().get();
  }
  </code></pre>
  
  <p>The problem is, I want it to return <code>null</code> if no value is present, how would I go amongst doing that? Because as it stands, that just throws a <code>NoSuchElementException</code>.</p>