title: How to negate a method reference predicate
body: <p>In Java 8, you can use a method reference to filter a stream, for example:</p>
  
  <pre><code>Stream&lt;String&gt; s = ...;
  long emptyStrings = s.filter(String::isEmpty).count();
  </code></pre>
  
  <p>Is there a way to create a method reference that is the negation of an existing one, i.e. something like:</p>
  
  <pre><code>long nonEmptyStrings = s.filter(not(String::isEmpty)).count();
  </code></pre>
  
  <p>I could create the <code>not</code> method like below but I was wondering if the JDK offered something similar.</p>
  
  <pre><code>static &lt;T&gt; Predicate&lt;T&gt; not(Predicate&lt;T&gt; p) { return o -&gt; !p.test(o); }
  </code></pre>