]> git.mxchange.org Git - jshop-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 31 Jan 2023 14:16:35 +0000 (15:16 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 31 Jan 2023 14:17:51 +0000 (15:17 +0100)
- avoid local variables when possible

src/org/mxchange/jshopcore/model/basket/BaseBasket.java
src/org/mxchange/jshopcore/model/basket/Basket.java

index 30f3f140d3f28111e8b732c07fdce711693bfe3a..ffa5837535a3305243c5374d1b1521046a22be5b 100644 (file)
@@ -72,7 +72,7 @@ public abstract class BaseBasket<T extends AddableBasketItem> implements Basket<
        @Override
        public List<T> getAll () {
                // Init map
-               List<T> list = new LinkedList<>();
+               final List<T> list = new LinkedList<>();
 
                // Iterate over full item list
                for (final T item : this.deque) {
@@ -104,16 +104,13 @@ public abstract class BaseBasket<T extends AddableBasketItem> implements Basket<
                        throw new NullPointerException("item is null"); //NOI18N
                }
 
-               // Get all items
-               List<T> 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;
index 117f693f18e6566d0fb30d850b8f7d9d7771d1d8..68267c5c18d61d286ef9eec7f7f57ae666cdd383 100644 (file)
@@ -33,15 +33,8 @@ public interface Basket<T extends AddableBasketItem> extends Serializable {
         * <p>
         * @param item Item instance to add
         * <p>
-        * @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;