throw new IllegalArgumentException(MessageFormat.format("event.addedBranchOffice .branchId={0} is not valid", event.getAddedBranchOffice().getBranchId())); //NOI18N
}
- // Add instance to cache
- this.branchOfficeCache.put(event.getAddedBranchOffice().getBranchId(), event.getAddedBranchOffice());
+ // Uniquely add branch office
this.uniqueAddBranchOffice(event.getAddedBranchOffice());
}
throw new IllegalArgumentException(MessageFormat.format("event.updatedBranchOffice .branchId={0} is not valid", event.getUpdatedBranchOffice().getBranchId())); //NOI18N
}
- // Add instance to cache
- this.branchOfficeCache.put(event.getUpdatedBranchOffice().getBranchId(), event.getUpdatedBranchOffice());
+ // Uniquely update branch office
this.uniqueAddBranchOffice(event.getUpdatedBranchOffice());
}
* @param branchOffice Branch office being added
*/
private void uniqueAddBranchOffice (final BranchOffice branchOffice) {
+ // Add instance to cache
+ this.branchOfficeCache.put(branchOffice.getBranchId(), branchOffice);
+
// Get iterator
final Iterator<BranchOffice> iterator = this.getAllBranchOffices().iterator();
throw new IllegalArgumentException(MessageFormat.format("event.addedDepartment.branchId={0} is not valid", event.getAddedDepartment().getDepartmentId())); //NOI18N
}
- // Add instance to cache
- this.departmentCache.put(event.getAddedDepartment().getDepartmentId(), event.getAddedDepartment());
+ // Uniquely add department
this.uniqueAddDepartment(event.getAddedDepartment());
}
throw new IllegalArgumentException(MessageFormat.format("event.updatedDepartment.branchId={0} is not valid", event.getUpdatedDepartment().getDepartmentId())); //NOI18N
}
- // Add instance to cache
- this.departmentCache.put(event.getUpdatedDepartment().getDepartmentId(), event.getUpdatedDepartment());
-
// Uniquely add (update) instance
this.uniqueAddDepartment(event.getUpdatedDepartment());
}
}
/**
- * Uniquely adds given department instance to full list
+ * Uniquely adds given department instance to full list and updates cache.
* <p>
* @param department Department being uniquely added
*/
private void uniqueAddDepartment (final Department department) {
+ // Add instance to cache
+ this.departmentCache.put(department.getDepartmentId(), department);
+
// Get iterator
final Iterator<Department> iterator = this.getAllDepartments().iterator();