]> git.mxchange.org Git - jproduct-core.git/blob - src/org/mxchange/jshopcore/model/basket/Basket.java
679200ae0a70a80d8fe38167850453223491170f
[jproduct-core.git] / src / org / mxchange / jshopcore / model / basket / Basket.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jshopcore.model.basket;
18
19 import java.io.IOException;
20 import java.io.Serializable;
21 import java.lang.reflect.InvocationTargetException;
22 import java.sql.SQLException;
23 import java.util.Map;
24 import org.mxchange.jshopcore.model.item.AddableBasketItem;
25
26 /**
27  * An interface for baskets
28  *
29  * @author Roland Haeder
30  * @param <T> Any addable basket items
31  */
32 public interface Basket<T extends AddableBasketItem> extends Serializable {
33
34         /**
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?
42          */
43         public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
44
45         /**
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
48          *
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?
56          */
57         public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
58
59         /**
60          * Checks if the basket is empty
61          *
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?
68          */
69         public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
70
71         /**
72          * Initializes this instance with given ServletContext
73          *
74          * @throws java.sql.SQLException If an SQL error occurs
75          * @throws java.io.IOException If an IO error occurs
76          */
77         public void init () throws SQLException, IOException;
78
79         /**
80          * Some "getter" for all entries in this basket
81          *
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?
88          */
89         public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
90
91         /**
92          * Getter for last entry
93          *
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?
100          */
101         public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
102
103         /**
104          * Getter for last num rows
105          * 
106          * @return Last num rows
107          */
108         public int getLastNumRows ();
109 }