| /home/oracle/labs/06CollectionOperations/examples/EmployeeSearch/src/com/example/lambda/A03FindFirst.java |
1 package com.example.lambda;
2
3 import java.util.List;
4 import java.util.Optional;
5
6
7
8 @author
9
10 public class A03FindFirst {
11
12 public static void main(String[] args) {
13
14 List<Employee> eList = Employee.createShortList();
15
16 System.out.println("\n== First CO Bonus ==");
17 Optional<Employee> result;
18
19 result = eList.stream()
20 .filter(e -> e.getRole().equals(Role.EXECUTIVE))
21 .filter(e -> e.getState().equals("CO"))
22 .findFirst();
23
24 if (result.isPresent()){
25 result.get().print();
26 }
27
28 }
29
30 }
31