/home/oracle/labs/06CollectionOperations/examples/EmployeeSearch/src/com/example/lambda/VacationTest.java
 1 package com.example.lambda;
 2 
 3 import java.time.LocalDate;
 4 import static java.time.temporal.ChronoUnit.DAYS;
 5 import java.util.List;
 6 
 7 public class VacationTest {
 8     
 9     public static void main(String[] args) {
10         
11         List<Employee> eList = Employee.createShortList();
12         
13         // Calc accrued days
14         LocalDate yearStart = LocalDate.of(2014,1,1);
15         long dayCount = yearStart.until(LocalDate.now(), DAYS);
16                         
17         // Print Starting values
18         System.out.println("\nDays: " + dayCount);
19         System.out.printf("Vacation Accrual Exec, Manager, Staff: %2.4f, %2.4f, %2.4f%n", 
20             VacAccrual.EXECUTIVE.perDay(), VacAccrual.MANAGER.perDay(), VacAccrual.STAFF.perDay());
21             
22         
23         // Print Vacation Summary Managers
24         System.out.println("\n== Vacation Summary List ==");
25         eList.stream()
26             .filter(e -> e.getRole().equals(Role.MANAGER))
27             .forEach(
28                 e -> System.out.printf(
29                     " Name: " + e.getGivenName() + " " +
30                     e.getSurName() + " Role: " + e.getRole() + " Dept: " + 
31                     e.getDept() + " ST: " + e.getState() +
32                     " Vacation: %,6.4f %n", VacAccrual.byRole(e.getRole()) * dayCount
33                 )
34             );
35 
36         // Print Vacation Summary Staff
37         System.out.println("\n== Vacation Summary List ==");
38         eList.stream()
39             .filter(e -> e.getRole().equals(Role.STAFF))
40             .forEach(
41                 e -> System.out.printf(
42                     " Name: " + e.getGivenName() + " " +
43                     e.getSurName() + " Role: " + e.getRole() + " Dept: " + 
44                     e.getDept() + " ST: " + e.getState() +
45                     " Vacation: %,6.4f %n", VacAccrual.byRole(e.getRole()) * dayCount
46                 )
47             );        
48         
49         // Print Vacation Summary Staff
50         System.out.println("\n== Exec Bonus Summary List ==");
51         eList.stream()
52             .filter(e -> e.getRole().equals(Role.EXECUTIVE))
53             .forEach(
54                 e -> System.out.printf(
55                     "Name: " + e.getGivenName() + " " +
56                     e.getSurName() + " Role: " + e.getRole() + " Dept: " + 
57                     e.getDept() + " ST: " + e.getState() +
58                     " Bonus: %,6.2f %n", Bonus.byRole(e.getRole()) * e.getSalary())
59             );        
60 
61     }
62 }
63