diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java index 429120eb..cc5a39b1 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenModel.java @@ -35,15 +35,15 @@ class StockScreenModel { } void commitProductDeletion(Product product) { - + stockService.commitUpdate(stockService.getNewUpdateBuilder().removeProduct(product)); } void commitProductModification(Product oldProduct, Product newProduct) { - + stockService.commitUpdate(stockService.getNewUpdateBuilder().modifyProduct(oldProduct, newProduct)); } void commitProductAddition(Product product) { - + stockService.commitUpdate(stockService.getNewUpdateBuilder().addProduct(product)); } void addListener(IStockScreenModelListener l){ diff --git a/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java b/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java index 36826f26..f471916b 100644 --- a/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java +++ b/Workspace/client/src/main/java/com/pqt/client/module/stock/UpdateBuilder.java @@ -16,20 +16,23 @@ public class UpdateBuilder { toModify = new HashMap<>(); } - public void addProduct(Product product) { + public UpdateBuilder addProduct(Product product) { if(!toAdd.contains(product)){ toAdd.add(product); } + return this; } - public void removeProduct(Product product) { + public UpdateBuilder removeProduct(Product product) { if(toRemove.contains(product)){ toRemove.remove(product); } + return this; } - public void modifyProduct(Product oldVersion, Product newVersion) { + public UpdateBuilder modifyProduct(Product oldVersion, Product newVersion) { toModify.put(oldVersion, newVersion); + return this; } public List build() {