From: Roland Haeder Date: Fri, 11 Sep 2015 09:53:09 +0000 (+0200) Subject: Added equals() and hashCode() for easy item comparison. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5aed37f8e1a21fcea34fd17f2f547479da359d0a;p=jcustomer-core.git Added equals() and hashCode() for easy item comparison. Signed-off-by:Roland Häder --- diff --git a/src/org/mxchange/jshopcore/model/basket/BaseBasket.java b/src/org/mxchange/jshopcore/model/basket/BaseBasket.java index 2a4de12..aac4020 100644 --- a/src/org/mxchange/jshopcore/model/basket/BaseBasket.java +++ b/src/org/mxchange/jshopcore/model/basket/BaseBasket.java @@ -20,7 +20,6 @@ import java.util.Deque; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.Map; -import java.util.Objects; import org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException; /** @@ -121,11 +120,11 @@ public abstract class BaseBasket implements Basket< boolean isAdded = false; for (Map.Entry entrySet : map.entrySet()) { - // Get item id - Long itemId = entrySet.getKey(); + // Get whole item + T i = entrySet.getValue(); // Compare id - if (Objects.equals(itemId, item.getItemId())) { + if (i.equals(item)) { // Okay, found it isAdded = true; break; diff --git a/src/org/mxchange/jshopcore/model/item/BaseItem.java b/src/org/mxchange/jshopcore/model/item/BaseItem.java index 7a8d50c..2015d2d 100644 --- a/src/org/mxchange/jshopcore/model/item/BaseItem.java +++ b/src/org/mxchange/jshopcore/model/item/BaseItem.java @@ -127,4 +127,31 @@ public abstract class BaseItem implements AddableBasketItem, Comparable