*/
package org.mxchange.jshopcore.model.basket;
-import java.io.IOException;
import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
-import java.util.Map;
-import org.mxchange.jshopcore.model.item.AddableBasketItem;
+import java.util.List;
+import org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException;
/**
* An interface for baskets
- *
- * @author Roland Haeder
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
* @param <T> Any addable basket items
*/
public interface Basket<T extends AddableBasketItem> extends Serializable {
/**
* Adds given item instance to this basket
+ * <p>
* @param item Item instance to add
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
- */
- public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
- /**
- * 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
- *
- * @param item Item instance to check
- * @return Whether the given item has been found
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
- */
- public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
- /**
- * Checks if the basket is empty
- *
- * @return Whether the basket is empty
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+ * @throws org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException
+ * If the item instance has already been added
*/
- public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+ public void addItem (final T item) throws BasketItemAlreadyAddedException;
/**
- * Initializes this instance with given ServletContext
- *
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.io.IOException If an IO error occurs
+ * Clears the basket instance
*/
- public void init () throws SQLException, IOException;
+ public void clear ();
/**
* Some "getter" for all entries in this basket
- *
+ * <p>
* @return Map on all basket items
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
*/
- public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+ public List<T> getAll ();
/**
* Getter for last entry
- *
+ * <p>
* @return Last added item in basket
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
*/
- public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+ public T getLast ();
/**
* Getter for last num rows
- *
+ * <p>
* @return Last num rows
*/
public int getLastNumRows ();
+
+ /**
+ * Checks whether the given item has already been added by checking the
+ * item's id.
+ * <p>
+ * @param item Item instance to check
+ * @return Whether the given item has been found
+ */
+ public boolean isAdded (final T item);
+
+ /**
+ * Checks if the basket is empty
+ * <p>
+ * @return Whether the basket is empty
+ */
+ public boolean isEmpty ();
}