From 2cbe949b03addfda64d1bc78cd01c8095d75a07c Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sat, 19 Aug 2017 20:54:35 +0200 Subject: [PATCH] =?UTF-8?q?Module=20Client=20:=20correction=20bug=20commit?= =?UTF-8?q?=20update=20StockScreenModel;=20Les=20m=C3=A9thds=20de=20la=20c?= =?UTF-8?q?lss=20UpdateBuilder=20sont=20d=C3=A9sormais=20chainables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/modules/stock_screen/StockScreenModel.java | 6 +++--- .../java/com/pqt/client/module/stock/UpdateBuilder.java | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) 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() {