title: How to filter a list of object by multiple fields in Java?
body: <p>I would like to filter a list of object by multiple fields but these fields, which used for filtering can change. For example;</p>
  
  <p>Assume that we have an Employee class with some properties:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Data
  public class Employee {
     private Integer id;
     private Integer age;
     private String gender;
     private String firstName;
     private String lastName;
  
  }
  </code></pre>
  
  <p>What is the best way to code a method that filter by sometimes age and gender or sometimes only firstName? (Samples can be reproduced, i.e. for this example it has 5 properties, so there are 5! = 120 possibilities)
  Could it be coded using lambda or something else in Java?</p>
  
  <p>P.S. : Any possibilities are not predefined. Whatever comes from the request it should filter by it. I believe the example below will make this issue clear:</p>
  
  <p>Assume that we have a Filter object with the same properties as Employee's. If age is given and the others are null, this service will filter only by age. Or only gender and firstName are given, it should get employees by the criteria.</p>