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;
26 * An interface for baskets
28 * @author Roland Haeder
29 * @param <T> Any addable basket items
31 public interface Basket<T extends AddableBasketItem> extends Serializable {
34 * Adds given item instance to this basket
35 * @param item Item instance to add
36 * @throws java.io.IOException If an IO error occurs
37 * @throws java.sql.SQLException If an SQL error occurs
38 * @throws java.lang.NoSuchMethodException If a method was not found
39 * @throws java.lang.IllegalAccessException If the invoked method is not public
40 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
42 public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
45 * Checks whether the given item as already been added. If the product's
46 * item id number was found in basket, the corresponding item instance will be set
48 * @param item Item instance to check
49 * @return Whether the given item has been found
50 * @throws java.io.IOException If an IO error occurs
51 * @throws java.sql.SQLException If an SQL error occurs
52 * @throws java.lang.NoSuchMethodException If a method was not found
53 * @throws java.lang.IllegalAccessException If the invoked method is not public
54 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
56 public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
59 * Checks if the basket is empty
61 * @return Whether the basket is empty
62 * @throws java.io.IOException If an IO error occurs
63 * @throws java.sql.SQLException If an SQL error occurs
64 * @throws java.lang.NoSuchMethodException If a method was not found
65 * @throws java.lang.IllegalAccessException If the invoked method is not public
66 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
68 public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
71 * Initializes this instance with given ServletContext
73 * @throws java.sql.SQLException If an SQL error occurs
74 * @throws java.io.IOException If an IO error occurs
76 public void init () throws SQLException, IOException;
79 * Some "getter" for all entries in this basket
81 * @return Map on all basket items
82 * @throws java.io.IOException If an IO error occurs
83 * @throws java.sql.SQLException If an SQL error occurs
84 * @throws java.lang.NoSuchMethodException If a method was not found
85 * @throws java.lang.IllegalAccessException If the invoked method is not public
86 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
88 public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
91 * Getter for last entry
93 * @return Last added item in basket
94 * @throws java.io.IOException If an IO error occurs
95 * @throws java.sql.SQLException If an SQL error occurs
96 * @throws java.lang.NoSuchMethodException If a method was not found
97 * @throws java.lang.IllegalAccessException If the invoked method is not public
98 * @throws java.lang.reflect.InvocationTargetException If anything else happened?
100 public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
103 * Getter for last num rows
105 * @return Last num rows
107 public int getLastNumRows ();