title: Are the || ('or') symbol and Stream.of(..).anyMatch(e-> e==true) functionally equivalent?
body: <p>Are <code>||</code> and <code>Stream.of(..).anyMatch(e-&gt; e==true)</code> functionally equivalent when applied to the same series of conditions in the same order?</p>
  
  <p>Task: Run a quick test on a series of conditions to determine whether any are true.</p>
  
  <p>Possible solutions:
   - Separate each condition with an ‘or’ symbol (<code>||</code>)
   - Include each condition in a <code>Stream.of(..)</code> statement that is appended with <code>.anyMatch(e-&gt; e==true)</code></p>
  
  <p>The documentation for <code>anyMatch(..)</code> states, “Returns whether any elements of this stream match the provided predicate. <em>May not evaluate the predicate on all elements if not necessary for determining the result</em> [emphasis added].”</p>
  
  <p>Based on this statement, my understanding is that the two solutions indicated above are functionally the same, so that if the second element in a serious of four is the first element that is <code>true</code>, then elements three and four won’t be evaluated.</p>
  
  <p>In practice, however, this seems not to be true. Consider the following where <code>item</code> is <code>null</code>, <code>empty</code> is <code>true</code> and <code>UtilMethods.isEmpty(..)</code> is a custom library method that tests if a given parameter is <code>null</code> or an empty <code>String</code> (""):</p>
  
  <pre><code>@Override
  protected void updateItem(Pair&lt;K, V&gt; item, boolean empty) {
      super.updateItem(item, empty);
  
      boolean test1 = empty
               || Objects.isNull(item)
               || UtilMethods.isEmpty(item.toString())
               || Objects.isNull(item.getValue());
  
      boolean test2 = Stream.of(
          empty,
          isNull(item),
          UtilMethods.isEmpty(item.toString()),
          isNull(item.getValue()))
      .anyMatch(e -&gt; e == true);
  }
  </code></pre>
  
  <p>The <code>||</code> code runs as expected. However, the <code>Stream.of(..).anyMatch(..)</code> throws a <code>NullPointerException</code> when the third element is reached because <code>item</code> is <code>null</code>.</p>
  
  <p>This doesn’t make sense in view of the documentation for <code>anyMatch(..)</code> that is referenced above, which suggests that the third element shouldn’t even be reached. Or am I missing something here? </p>
  
  <p>Thanks</p>