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