Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1.     private Map<String, List<Attendance>> collectAttendancesByUsers(List<Attendance> attendances) {
  2.         //comparing with login - because Employee class does not have own equals/hashcode
  3.         Map<String, List<Attendance>> employeeMap = new HashMap<>();
  4.         for (Attendance att : attendances) {
  5.             String login = att.getEmployee().getLogin();
  6.             List<Attendance> employeeAttendances = employeeMap.get(login);
  7.             if (employeeAttendances == null) {
  8.                 employeeAttendances = new ArrayList<>();
  9.                 employeeMap.put(login, employeeAttendances);
  10.             }
  11.             employeeAttendances.add(att);
  12.         }
  13.         return employeeMap;
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement