]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 12 May 2020 03:58:08 +0000 (05:58 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 12 May 2020 03:58:08 +0000 (05:58 +0200)
- cache can be updated from the uniqueAddFoo() method

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/business/branchoffice/list/FinancialsBranchOfficeListWebViewBean.java
src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewBean.java

index f525430897cb315c87ec38c82b404d7bf87062f0..7a41a1d2798b007a876e70d8fc04964c394cfc10 100644 (file)
@@ -112,8 +112,7 @@ public class FinancialsBranchOfficeListWebViewBean extends BaseFinancialsBean im
                        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());
        }
 
@@ -139,8 +138,7 @@ public class FinancialsBranchOfficeListWebViewBean extends BaseFinancialsBean im
                        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());
        }
 
@@ -275,6 +273,9 @@ public class FinancialsBranchOfficeListWebViewBean extends BaseFinancialsBean im
         * @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();
 
index be23270b6bf7ed58d7af28c1e56ded5a9aba8811..b057f2dd67de4a3328e91eb186e80911361143d0 100644 (file)
@@ -113,8 +113,7 @@ public class FinancialsDepartmentListWebViewBean extends BaseFinancialsBean impl
                        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());
        }
 
@@ -140,9 +139,6 @@ public class FinancialsDepartmentListWebViewBean extends BaseFinancialsBean impl
                        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());
        }
@@ -268,11 +264,14 @@ public class FinancialsDepartmentListWebViewBean extends BaseFinancialsBean impl
        }
 
        /**
-        * 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();