From: Roland Häder Date: Tue, 31 Jan 2023 14:16:35 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b24021b8551fdcc40d85d24051499a725b53451b;p=jshop-core.git Continued: - avoid local variables when possible --- diff --git a/src/org/mxchange/jshopcore/model/basket/BaseBasket.java b/src/org/mxchange/jshopcore/model/basket/BaseBasket.java index 30f3f14..ffa5837 100644 --- a/src/org/mxchange/jshopcore/model/basket/BaseBasket.java +++ b/src/org/mxchange/jshopcore/model/basket/BaseBasket.java @@ -72,7 +72,7 @@ public abstract class BaseBasket implements Basket< @Override public List getAll () { // Init map - List list = new LinkedList<>(); + final List list = new LinkedList<>(); // Iterate over full item list for (final T item : this.deque) { @@ -104,16 +104,13 @@ public abstract class BaseBasket implements Basket< throw new NullPointerException("item is null"); //NOI18N } - // Get all items - List list = this.getAll(); - // Default is not found boolean isAdded = false; // Loop through list - for (final T i : list) { + for (final T currentItem : this.getAll()) { // Compare id - if (i.equals(item)) { + if (currentItem.equals(item)) { // Okay, found it isAdded = true; break; diff --git a/src/org/mxchange/jshopcore/model/basket/Basket.java b/src/org/mxchange/jshopcore/model/basket/Basket.java index 117f693..68267c5 100644 --- a/src/org/mxchange/jshopcore/model/basket/Basket.java +++ b/src/org/mxchange/jshopcore/model/basket/Basket.java @@ -33,15 +33,8 @@ public interface Basket extends Serializable { *

* @param item Item instance to add *

- * @throws org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException - * If - * the - * item - * instance - * has - * already - * been - * added + * @throws BasketItemAlreadyAddedException If the item instance has already + * been added */ void addItem (final T item) throws BasketItemAlreadyAddedException;