From 0b8bb4e183689d8051ab33afacf14ff26bf5e335 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sun, 30 Jul 2017 13:27:09 +0200 Subject: [PATCH] =?UTF-8?q?Module=20Core,=20clss=20Product=20:=20Ajout=20c?= =?UTF-8?q?onstructeur=20de=20copie=20+=20modif=20m=C3=A9thode=20de=20copi?= =?UTF-8?q?e=20du=20contenu=20(utilisation=20des=20streams)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/pqt/core/entities/product/Product.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java b/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java index 2f72df2b..72fe0f8c 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/product/Product.java @@ -33,10 +33,14 @@ public class Product implements ILoggable, Serializable{ this.category = category; this.components = new ArrayList<>(); if(components!=null){ - this.components.addAll(components); + components.stream().forEach(p->this.components.add(new Product(p))); } } + public Product(Product p) { + this(p.id, p.name, p.amountRemaining, p.amountSold, p.sellable, p.price, p.components, p.category); + } + public long getId() { return id; }