title: Java filter List that so it only contains objects that have same attribute as in another lists
body: <p>I got 2 lists containing several objects. I want to filter the objects that contain the same String value at a specific attribute.
  So let's say <code>listA</code> contains objects with attribute <code>id</code>. Same for <code>listB</code>, although it contains different objects. Some objects from both lists have the same id though. I want to filter these objects and put them in the a new list. This is what i got so far:</p>
  
  <pre><code>List&lt;Customer&gt; Clist = Customer.getAllCustomers();
      List&lt;License&gt; Llist = License.getAllLicenses();
  
      Predicate&lt;Customer&gt; customerNotNullPredicate = u -&gt; (u.id != null);
      Predicate&lt;License&gt; licenseNotNullPredicate = u -&gt; (u.id != null);
  
      List&lt;Customer&gt; Clistfiltered1 = Clist.parallelStream().filter(customerNotNullPredicate).collect(Collectors.toList());
      List&lt;License&gt; Llistfiltered1 = Llist.parallelStream().filter(licenseNotNullPredicate).collect(Collectors.toList());
      Clistfiltered1.retainAll(Llistfiltered1);
      try {
          Clistfiltered1.get(0);
      } catch (Exception e){
          System.out.println(e);
      }
  </code></pre>
  
  <p>If course, <code>retainAll()</code> doesn't return anything, as both lists just contain objects of the different type. How can i try to use <code>retainAll()</code> on a specific attribute of the objects?</p>
  
  <p>Thank you a lot in advance.</p>