title: Check if something is equal to null or empty using lambdas
body: <p>I have a class that counts the average number of words in a sentence using Lambdas in java.  The problem that I'm having is that if corp is null or is empty I need to return 0.  Currently I am getting NaN if corp is either null or empty.  The rest of my code does what it should, but I cannot figure this part out.</p>
  
  <pre><code>public class AverageNumberOfWordsPerSentence extends TextMetric&lt;Double&gt; {
  @Override
  public Double apply(final Corpus corp) {
      Sentences sentences = new Sentences();
      List&lt;String&gt; sentenceList = sentences.apply(corp);
  
      LongSummaryStatistics lss = corp.texts().stream()
                                      .map(blob -&gt; blob.text())
                                      .flatMap(string -&gt; stream
                                      (string.split("\\W+")))
                                      .filter(string -&gt; !string.isEmpty())
                                      .mapToLong(String::length)
                                      .summaryStatistics();                                   
                                      return (double)lss.getCount() / 
                                                     sentenceList.size();
  }
  </code></pre>