From: Roland Haeder Date: Mon, 14 Sep 2015 08:40:29 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dcca35dd0d1e09db502e83a2ee38ee1167f77781;p=jcustomer-core.git Continued: - added method isProductType() - changed type of getAll() to List asthis is fine - updated jars Signed-off-by:Roland Häder --- diff --git a/lib/jcore-ee-logger.jar b/lib/jcore-ee-logger.jar index 6d0e98c..9631578 100644 Binary files a/lib/jcore-ee-logger.jar and b/lib/jcore-ee-logger.jar differ diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 925c058..20252ca 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ diff --git a/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java b/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java index 24997a8..163eefd 100644 --- a/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java +++ b/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java @@ -95,4 +95,11 @@ public interface AddableBasketItem extends Serializable { * @param product the product to set */ public void setProduct (final Product product); + + /** + * Determines whether the item has a Product instance set + * + * @return Whether a Product instance is set + */ + public boolean isProductType (); } diff --git a/src/org/mxchange/jshopcore/model/basket/BaseBasket.java b/src/org/mxchange/jshopcore/model/basket/BaseBasket.java index aac4020..06755b1 100644 --- a/src/org/mxchange/jshopcore/model/basket/BaseBasket.java +++ b/src/org/mxchange/jshopcore/model/basket/BaseBasket.java @@ -17,9 +17,8 @@ package org.mxchange.jshopcore.model.basket; import java.util.Deque; -import java.util.LinkedHashMap; import java.util.LinkedList; -import java.util.Map; +import java.util.List; import org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException; /** @@ -70,9 +69,9 @@ public abstract class BaseBasket implements Basket< } @Override - public Map getAll () { + public List getAll () { // Init map - Map map = new LinkedHashMap<>(this.deque.size()); + List list = new LinkedList<>(); // Iterate over full item list for (T item : this.deque) { @@ -83,11 +82,11 @@ public abstract class BaseBasket implements Basket< } // Add to map, use the item's id as key - map.put(item.getItemId(), item); + list.add(item); } // Return it - return map; + return list; } @Override @@ -114,15 +113,13 @@ public abstract class BaseBasket implements Basket< } // Get all items - Map map = this.getAll(); + List list = this.getAll(); // Default is not found boolean isAdded = false; - for (Map.Entry entrySet : map.entrySet()) { - // Get whole item - T i = entrySet.getValue(); - + // Loop through list + for (final T i : list) { // Compare id if (i.equals(item)) { // Okay, found it diff --git a/src/org/mxchange/jshopcore/model/basket/Basket.java b/src/org/mxchange/jshopcore/model/basket/Basket.java index 8e17339..f0824bb 100644 --- a/src/org/mxchange/jshopcore/model/basket/Basket.java +++ b/src/org/mxchange/jshopcore/model/basket/Basket.java @@ -17,7 +17,7 @@ package org.mxchange.jshopcore.model.basket; import java.io.Serializable; -import java.util.Map; +import java.util.List; import org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException; /** @@ -57,7 +57,7 @@ public interface Basket extends Serializable { * * @return Map on all basket items */ - public Map getAll (); + public List getAll (); /** * Getter for last entry diff --git a/src/org/mxchange/jshopcore/model/item/BaseItem.java b/src/org/mxchange/jshopcore/model/item/BaseItem.java index 2015d2d..8e4591e 100644 --- a/src/org/mxchange/jshopcore/model/item/BaseItem.java +++ b/src/org/mxchange/jshopcore/model/item/BaseItem.java @@ -154,4 +154,10 @@ public abstract class BaseItem implements AddableBasketItem, Comparable