Iterator iterator = new ArrayList(aa.getSchedule()).iterator(); while (iterator.hasNext()) {
Schedule currentSchedule = ldmf.newSchedule(new Enumerator(currentAvailability));  for (Iterator localIterator = new ArrayList(currentSchedule).iterator(), aaIterator = new ArrayList(aa.getSchedule()).iterator(); localIterator.hasNext();) { ScheduleElement localElement = (ScheduleElement) localIterator.next(); ScheduleElement aaElement = (ScheduleElement) aaIterator.next();   if ((localElement.getStartTime() != aaElement.getStartTime()) || (localElement.getEndTime() != aaElement.getEndTime())) { availSchedule.removeAll(currentAvailability); change = true; break; } } } else { change = true; }  if (change) {   for (Iterator iterator = new ArrayList(aa.getSchedule()).iterator(); iterator.hasNext();) {
  private void fixAvailSchedule(AssetAssignment aa, Asset asset,                                final Asset assignee) {    NewSchedule availSchedule =       (NewSchedule)asset.getRoleSchedule().getAvailableSchedule();    if (availSchedule == null) {      availSchedule = ldmf.newAssignedAvailabilitySchedule();      ((NewRoleSchedule)asset.getRoleSchedule()).setAvailableSchedule(availSchedule);    }    synchronized (availSchedule) {      if ((aa.isUpdate() || aa.isRepeat()) ||           (related(asset) && related(assignee))) {        Collection remove = availSchedule.filter(new UnaryPredicate() {          public boolean execute(Object o) {            return ((o instanceof AssignedAvailabilityElement) &&                     (((AssignedAvailabilityElement)o).getAssignee().equals(assignee)));          }        });        availSchedule.removeAll(remove);      }            //Add entries to the available schedule using the assignee      if (related(asset) && related(assignee)) {        //Construct aggregate avail info from the relationship schedule        RelationshipSchedule relationshipSchedule =           ((HasRelationships)asset).getRelationshipSchedule();        Collection collection =           relationshipSchedule.getMatchingRelationships((HasRelationships)assignee,                                                        ETERNITY);                // If any relationships, add a single avail element with the         // min start and max end        if (collection.size() > 0) {          Schedule schedule = ldmf.newSchedule(new Enumerator(collection));          availSchedule.add(ldmf.newAssignedAvailabilityElement(assignee,                                                                schedule.getStartTime(),                                                                schedule.getEndTime()));        }      } else {        //Copy availability info directly from aa schedule        //Don't iterate over schedule directly because Schedule doesn't support        //iterator().        Iterator iterator = new ArrayList(aa.getSchedule()).iterator();        while (iterator.hasNext()) {          ScheduleElement avail = (ScheduleElement)iterator.next();          availSchedule.add(ldmf.newAssignedAvailabilityElement(assignee,                                                                 avail.getStartTime(),                                                                avail.getEndTime()));        }      }    } // end sync block  }