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.jshopcore.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.jshopcore.model.item.AddableBasketItem;
27 * An interface for baskets
29 * @author Roland Haeder
30 * @param <T> Any addable basket items
32 public interface Basket<T extends AddableBasketItem> extends Serializable {
35 * Adds given item instance to this basket
36 * @param item Item instance to add
37 * @throws java.io.IOException If an IO error occurs
38 * @throws java.sql.SQLException If an SQL error occurs
39 * @throws java.lang.NoSuchMethodException If a method was not found
40 * @throws java.lang.IllegalAccessException If the invoked method is not public
41 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
43 public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
46 * Checks whether the given item as already been added. If the product's
47 * item id number was found in basket, the corresponding item instance will be set
49 * @param item Item instance to check
50 * @return Whether the given item has been found
51 * @throws java.io.IOException If an IO error occurs
52 * @throws java.sql.SQLException If an SQL error occurs
53 * @throws java.lang.NoSuchMethodException If a method was not found
54 * @throws java.lang.IllegalAccessException If the invoked method is not public
55 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
57 public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
60 * Checks if the basket is empty
62 * @return Whether the basket is empty
63 * @throws java.io.IOException If an IO error occurs
64 * @throws java.sql.SQLException If an SQL error occurs
65 * @throws java.lang.NoSuchMethodException If a method was not found
66 * @throws java.lang.IllegalAccessException If the invoked method is not public
67 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
69 public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
72 * Initializes this instance with given ServletContext
74 * @throws java.sql.SQLException If an SQL error occurs
75 * @throws java.io.IOException If an IO error occurs
77 public void init () throws SQLException, IOException;
80 * Some "getter" for all entries in this basket
82 * @return Map on all basket items
83 * @throws java.io.IOException If an IO error occurs
84 * @throws java.sql.SQLException If an SQL error occurs
85 * @throws java.lang.NoSuchMethodException If a method was not found
86 * @throws java.lang.IllegalAccessException If the invoked method is not public
87 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
89 public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
92 * Getter for last entry
94 * @return Last added item in basket
95 * @throws java.io.IOException If an IO error occurs
96 * @throws java.sql.SQLException If an SQL error occurs
97 * @throws java.lang.NoSuchMethodException If a method was not found
98 * @throws java.lang.IllegalAccessException If the invoked method is not public
99 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
101 public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
104 * Getter for last num rows
106 * @return Last num rows
108 public int getLastNumRows ();