]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java
Continued:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / basket / BasketWebController.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.pizzaapplication.beans.basket;
18
19 import java.io.Serializable;
20 import java.util.List;
21 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
22 import org.mxchange.jshopcore.model.product.Product;
23
24 /**
25  * An interface for a basket
26  *
27  * @author Roland Haeder<roland@mxchange.org>
28  */
29 public interface BasketWebController extends Serializable {
30
31         /**
32          * Checks whether the basket is empty
33          *
34          * @return Whether the basket is empty
35          */
36         public boolean isEmpty ();
37
38         /**
39          * Checks whether the basket has items in it. This method is wrapper to
40          * isEmpty()
41          *
42          * @return Whether the basket is empty
43          */
44         public boolean hasItems ();
45
46         /**
47          * Checks whether the currently set product is added in basked
48          *
49          * @param product Product instance
50          * @return Whether the product is added
51          */
52         public boolean isProductAdded (final Product product);
53
54         /**
55          * Adds given product instance to basket by adding amount from form data to
56          * it.
57          *
58          * @param product Product instance to add
59          * @return Redirect target or null
60          */
61         public String addItem (final Product product);
62
63         /**
64          * Getter for item amount property
65          *
66          * @return Item amount property
67          */
68         public Long getAmount ();
69
70         /**
71          * Setter for item amount property
72          *
73          * @param amount Item amount property
74          */
75         public void setAmount (final Long amount);
76
77         /**
78          * Getter for current item
79          *
80          * @return Current item
81          */
82         public AddableBasketItem getCurrentItem ();
83
84         /**
85          * Setter for current item
86          *
87          * @param currentItem Current item
88          */
89         public void setCurrentItem (final AddableBasketItem currentItem);
90
91         /**
92          * Calculates total price (no tax added) of current item. If no current item
93          * is set and no amount, a NPE is thrown.
94          *
95          * @return Current item's total price
96          */
97         public Float calculateCurrentItemPrice ();
98
99         /**
100          * Calculates total price (no tax added) for given item.
101          *
102          * @param item Item instance to calculate total price for
103          * @return Total price
104          */
105         public Float calculateItemPrice (final AddableBasketItem item);
106
107         /**
108          * Getter for last entry
109          *
110          * @return Last added item in basket
111          */
112         public AddableBasketItem getLast ();
113
114         /**
115          * Getter for last num rows
116          *
117          * @return Last num rows
118          */
119         public int getLastNumRows ();
120
121         /**
122          * Gets for all added items
123          *
124          * @return A list of all added items
125          */
126         public List<AddableBasketItem> allItems ();
127 }