2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jshop.model.basket;
19 import java.io.IOException;
20 import java.io.Serializable;
21 import java.lang.reflect.InvocationTargetException;
22 import java.sql.SQLException;
24 import org.mxchange.jshop.ShopInterface;
25 import org.mxchange.jshop.model.item.AddableBasketItem;
28 * An interface for baskets
30 * @author Roland Haeder
31 * @param <T> Any addable basket items
33 public interface Basket<T extends AddableBasketItem> extends Serializable, ShopInterface {
36 * Adds given item instance to this basket
37 * @param item Item instance to add
38 * @throws java.io.IOException If an IO error occurs
39 * @throws java.sql.SQLException If an SQL error occurs
40 * @throws java.lang.NoSuchMethodException If a method was not found
41 * @throws java.lang.IllegalAccessException If the invoked method is not public
42 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
44 public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
47 * Checks whether the given item as already been added. If the product's
48 * item id number was found in basket, the corresponding item instance will be set
50 * @param item Item instance to check
51 * @return Whether the given item has been found
52 * @throws java.io.IOException If an IO error occurs
53 * @throws java.sql.SQLException If an SQL error occurs
54 * @throws java.lang.NoSuchMethodException If a method was not found
55 * @throws java.lang.IllegalAccessException If the invoked method is not public
56 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
58 public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
61 * Checks if the basket is empty
63 * @return Whether the basket is empty
64 * @throws java.io.IOException If an IO error occurs
65 * @throws java.sql.SQLException If an SQL error occurs
66 * @throws java.lang.NoSuchMethodException If a method was not found
67 * @throws java.lang.IllegalAccessException If the invoked method is not public
68 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
70 public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
73 * Initializes this instance with given ServletContext
75 * @throws java.sql.SQLException If an SQL error occurs
76 * @throws java.io.IOException If an IO error occurs
78 public void init () throws SQLException, IOException;
81 * Some "getter" for all entries in this basket
83 * @return Map on all basket items
84 * @throws java.io.IOException If an IO error occurs
85 * @throws java.sql.SQLException If an SQL error occurs
86 * @throws java.lang.NoSuchMethodException If a method was not found
87 * @throws java.lang.IllegalAccessException If the invoked method is not public
88 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
90 public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
93 * Getter for last entry
95 * @return Last added item in basket
96 * @throws java.io.IOException If an IO error occurs
97 * @throws java.sql.SQLException If an SQL error occurs
98 * @throws java.lang.NoSuchMethodException If a method was not found
99 * @throws java.lang.IllegalAccessException If the invoked method is not public
100 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
102 public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
105 * Getter for last num rows
107 * @return Last num rows
109 public int getLastNumRows ();