]> git.mxchange.org Git - jcustomer-core.git/blob - src/org/mxchange/jshopcore/model/basket/Basket.java
Continued:
[jcustomer-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
25 /**
26  * An interface for baskets
27  *
28  * @author Roland Haeder
29  * @param <T> Any addable basket items
30  */
31 public interface Basket<T extends AddableBasketItem> extends Serializable {
32
33         /**
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?
41          */
42         public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
43
44         /**
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
47          *
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?
55          */
56         public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
57
58         /**
59          * Checks if the basket is empty
60          *
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?
67          */
68         public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
69
70         /**
71          * Initializes this instance with given ServletContext
72          *
73          * @throws java.sql.SQLException If an SQL error occurs
74          * @throws java.io.IOException If an IO error occurs
75          */
76         public void init () throws SQLException, IOException;
77
78         /**
79          * Some "getter" for all entries in this basket
80          *
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?
87          */
88         public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
89
90         /**
91          * Getter for last entry
92          *
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?
99          */
100         public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
101
102         /**
103          * Getter for last num rows
104          * 
105          * @return Last num rows
106          */
107         public int getLastNumRows ();
108 }