title: Checking equals for JAXB object considering some of the fields
body: <p>My autogenerated JAXB Class</p>
  
  <pre><code>public class Employee {
     private int id;
     private String name;
     private String department;
  
     /* Getters and Setters */
  
  }
  
  Employee emp1 = new Employee();
  emp1.setId(1);
  emp1.setName("A");
  emp1.setDepartment("D1");
  
  
  Employee emp2 = new Employee();
  emp2.setId(2);
  emp2.setName("B");
  emp2.setDepartment("D1");
  
  List&lt;Employee&gt; empList1 = new ArrayList&lt;Employee&gt;();
  empList1.add(emp1);
  empList2.add(emp2);
  
  Employee emp3 = new Employee();
  emp2.setId(3);
  emp2.setName("A");
  emp2.setDepartment("D1");
  
  List&lt;Employee&gt; empList2 = new ArrayList&lt;Employee&gt;();
  empList2.add(emp3);
  </code></pre>
  
  <blockquote>
    <p>I want to compare both the list empList1 and empList2 and get a result list which matches name and department fields of Employee object.</p>
  </blockquote>
  
  <p>Basically, I need intersection of two list based on the custom comparison of the fields in two objects.</p>
  
  <p>I was looking at Google Guava and lambdaJ but I was not able to find a solution/sample for doing intersection by custom comparison logic.</p>
  
  <p>Any idea would be helpful.</p>