I have a piece of code as follows and the idea is basically to process a fixed amount of items/ids each time based on LIMIT:
    List<Integer> employeeId = new ArrayList<>();
    for(Department d: getDepartments() {        
      for(Person p: d.getPersons()) {
         employeeId.add(p.getId());  
         if(employeeId.size() < LIMIT) {
          continue;
         }
         processIds(employeeId);  
         employeeId.clear();
       }
    }
    if(!employeeId.isEmpty()) {
      processIds(employeeId);  
    }
My question is: Is there a more idiomatic way e.g. using streams to write the code and would that be more performant?
Note: Reason I am asking for context is that I have not used streams in Java hence I am trying to understand more the usage. It is not the case that the code has been profiled and is slow
