/home/oracle/labs/06CollectionOperations/examples/EmployeeSearch06/src/com/example/lambda/A05AnyMatch.java
 1 package com.example.lambda;
 2 
 3 import java.util.List;
 4 import java.util.Optional;
 5 
 6 /**
 7  *
 8  * @author oracle
 9  */
10 public class A05AnyMatch {
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       if (eList.stream().anyMatch(
20           e -> e.getState().equals("CO"))){
21             
22         result = eList.stream()
23           .peek(e -> System.out.println("Stream"))
24           .filter(e -> e.getRole().equals(Role.EXECUTIVE))
25           .filter(e -> e.getState().equals("CO"))
26           .findFirst();
27 
28         if (result.isPresent()){result.get().printSummary();}
29       }
30         
31         System.out.println("\n== Any CA Bonus ==");
32         if (eList.stream().anyMatch(e -> e.getState().equals("CA"))){
33             result = eList.stream()
34                 .peek(e -> System.out.println("Stream"))
35                 .filter(e -> e.getRole().equals(Role.EXECUTIVE))
36                 .filter(e -> e.getState().equals("CO"))
37                 .findFirst();
38 
39         
40             if (result.isPresent()){
41                 result.get().print();
42             }
43         }
44         
45     }
46     
47 }
48