I am using java-8 to find the values in list of custom object. For ex)
List<Employee> employees = Arrays.asList(
new Employee("Sachin Tendulkar", 41),
new Employee("Sachin Tendulkar", 36),
new Employee("MS Dhoni", 34),
new Employee("Rahul Dravid", 40),
new Employee("Lokesh Rahul", 25),
new Employee("Sourav Ganguly", 40)
);
To find a value in a list i can use the below query,
boolean isPresent = employees.stream()
.allMatch(employee -> (equalsIgnoreCase(employee.getName(),"Sachin Tendulkar") && equalsIgnoreCase(employee.getAge(),"36")));
The above is working fine. But I would like to find "Sachin Tendulkar" with Age 36 and "Rahul Dravid" with 40. How to achieve this in Java8 streams. I have tried multiple "allMatch" but that doesn't work.
Any hint would be appreciable.