title: Handling null pointers and throwing exceptions in streams
body: <p>Let's consider a <code>Parent</code> class which contains only one <code>Integer</code> attribute.
  I created 6 objects of parent class and  with one null variable. Then I added these objects to a list.</p>
  <p>I want to retrieve the corresponding object by the value of <code>Integer</code> attribute.
  I used Java 8 Streams for it.</p>
  <pre><code>Predicate&lt;Parent&gt; predicate = e -&gt; e.getId() == 100; // sample attribute value
  result = list.stream().filter(predicate).collect(Collectors.toList());
  </code></pre>
  <p>But I got <code>NullPointerException</code>, so I edited the code:</p>
  <pre><code>list.stream().filter(h -&gt; h!=null).filter(predicate).collect(Collectors.toList());
  </code></pre>
  <p>But I want to throw an exception if any of the object is null. If no objects in the  list is null, then I want to retrieve the corresponding object from list.</p>
  <p>How can I achieve this using a single statement using Java 8 Streams?</p>