title: Validating a list using Java8 stream
body: <p>Lets say I have a <code>List&lt;Foo&gt;</code> objects and there is a <code>User</code> object inside <code>Foo</code>:</p>
  
  <pre><code>public class Foo {
     public User user;
  }
  
  public class User {
     int id;
     int typeId;
  }
  </code></pre>
  
  <p>Lets say I have a method that takes in a User object and a List objects. Is there an efficient way in Java8 to stream the Foo objects and return fast if any of the Foo objects' User is not the same as the User passed into the method?</p>
  
  <pre><code>public boolean validate(User loggedInUser, List&lt;Foo&gt; objectsToVerify);
  </code></pre>
  
  <p>The idea I have is to do:</p>
  
  <pre><code>return objectsToVerify.stream().filter(o -&gt; o.user != loggedInUser).collect(Collections.toList()).isEmpty();
  </code></pre>