]> git.mxchange.org Git - jproduct-core.git/commitdiff
updated jar + isAdded() cannot call contains() because the item instance is always...
authorRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 09:46:55 +0000 (11:46 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 09:46:55 +0000 (11:46 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcore-ee-logger.jar
src/org/mxchange/jshopcore/model/basket/BaseBasket.java
src/org/mxchange/jshopcore/model/basket/Basket.java

index 4edcfadfaec1a7ceec3691a58c99a6fa866423db..61710f119e55e9fc6facdf099f0a1ef34c06f439 100644 (file)
Binary files a/lib/jcore-ee-logger.jar and b/lib/jcore-ee-logger.jar differ
index f51055203f97a9e5098f3363f9943f93c1e367d9..2a4de120f7b119a20fb9af9bf303ceefc10244cf 100644 (file)
@@ -20,6 +20,7 @@ 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;
 
 /**
@@ -113,7 +114,24 @@ public abstract class BaseBasket<T extends AddableBasketItem> implements Basket<
                        throw new NullPointerException("item is null"); //NOI18N
                }
 
+               // Get all items
+               Map<Long, T> map = this.getAll();
+
+               // Default is not found
+               boolean isAdded = false;
+
+               for (Map.Entry<Long, T> 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;
        }
 }
index 51f4a58906952166510e7e8347f4ddd29debf38e..8e173391725b00d9d6438df7b55aa64922f7cbbc 100644 (file)
@@ -37,8 +37,8 @@ public interface Basket<T extends AddableBasketItem> 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