From 73b901e9d9e1638a493040c23f986df950b75d5d Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 11 Sep 2015 11:46:55 +0200 Subject: [PATCH] =?utf8?q?updated=20jar=20+=20isAdded()=20cannot=20call=20?= =?utf8?q?contains()=20because=20the=20item=20instance=20is=20always=20new?= =?utf8?q?.=20Instead=20it=20needs=20to=20check=20the=20(unique)=20item=20?= =?utf8?q?id.=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcore-ee-logger.jar | Bin 8032 -> 8032 bytes .../jshopcore/model/basket/BaseBasket.java | 20 +++++++++++++++++- .../jshopcore/model/basket/Basket.java | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/jcore-ee-logger.jar b/lib/jcore-ee-logger.jar index 4edcfadfaec1a7ceec3691a58c99a6fa866423db..61710f119e55e9fc6facdf099f0a1ef34c06f439 100644 GIT binary patch delta 212 zcmaE0_rQ)Pz?+$ci-CcIf#Gz_L>^71Q!x|Gr!xWB7ZgC`CruzZS(ecpM1?Whf~cvC z&LHX*qZg3cti}|>2%=k^71T}~6tr!xWB7ZgC`CruzZS(ecpM1?Whf~cvC z&LHX*qZd&1W;Lc5Mj&@{3$ro{h+fHV$ONMAaDL$c(U*kG!F+Df_pCtv implements Basket< throw new NullPointerException("item is null"); //NOI18N } + // Get all items + Map map = this.getAll(); + + // Default is not found + boolean isAdded = false; + + for (Map.Entry entrySet : map.entrySet()) { + // Get item id + Long itemId = entrySet.getKey(); + + // Compare id + if (Objects.equals(itemId, item.getItemId())) { + // Okay, found it + isAdded = true; + break; + } + } // Return it - return this.deque.contains(item); + return isAdded; } } diff --git a/src/org/mxchange/jshopcore/model/basket/Basket.java b/src/org/mxchange/jshopcore/model/basket/Basket.java index 51f4a58..8e17339 100644 --- a/src/org/mxchange/jshopcore/model/basket/Basket.java +++ b/src/org/mxchange/jshopcore/model/basket/Basket.java @@ -37,8 +37,8 @@ public interface Basket extends Serializable { public void addItem (final T item) throws BasketItemAlreadyAddedException; /** - * Checks whether the given item as already been added. If the product's - * item id number was found in basket, the corresponding item instance will be set + * Checks whether the given item has already been added by checking the + * item's id. * * @param item Item instance to check * @return Whether the given item has been found -- 2.39.5