]> 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          * Adds given product instance to basket by adding amount from form data to
33          * it.
34          *
35          * @param product Product instance to add
36          * @return Redirect target or null
37          */
38         public String addItem (final Product product);
39
40         /**
41          * Gets for all added items
42          *
43          * @return A list of all added items
44          */
45         public List<AddableBasketItem> allItems ();
46
47         /**
48          * Calculates total price (no tax added) of current item. If no current item
49          * is set and no amount, a NPE is thrown.
50          *
51          * @return Current item's total price
52          */
53         public Float calculateCurrentItemPrice ();
54
55         /**
56          * Calculates total price (no tax added) for given item.
57          *
58          * @param item Item instance to calculate total price for
59          * @return Total price
60          */
61         public Float calculateItemPrice (final AddableBasketItem item);
62
63         /**
64          * Calculates total sum (no tax added) for all items
65          *
66          * @return Total price of all items
67          */
68         public Float calculateTotalPrice ();
69
70         /**
71          * Changes given item instance's amount in basket and redirects to proper
72          * page. If the item is not found, another "error" page is called.
73          *
74          * @param item Item instance to change
75          * @return Page redirection
76          */
77         public String changeItem (final AddableBasketItem item);
78
79         /**
80          * Clears this basket instance
81          */
82         public void clear ();
83
84         /**
85          * Getter for item amount property
86          *
87          * @return Item amount property
88          */
89         public Long getAmount ();
90
91         /**
92          * Setter for item amount property
93          *
94          * @param amount Item amount property
95          */
96         public void setAmount (final Long amount);
97
98         /**
99          * Getter for current item
100          *
101          * @return Current item
102          */
103         public AddableBasketItem getCurrentItem ();
104
105         /**
106          * Setter for current item
107          *
108          * @param currentItem Current item
109          */
110         public void setCurrentItem (final AddableBasketItem currentItem);
111
112         /**
113          * Some getter for item amount of given product. This method requires a full
114          * iteration over all items in the basket to look for proper product
115          * instance.
116          *
117          * @param product Product instance
118          * @return Item amount of given product
119          */
120         public Long getItemAmount (final Product product);
121
122         /**
123          * Getter for last entry
124          *
125          * @return Last added item in basket
126          */
127         public AddableBasketItem getLast ();
128
129         /**
130          * Getter for last num rows
131          *
132          * @return Last num rows
133          */
134         public int getLastNumRows ();
135
136         /**
137          * Checks whether the basket has items in it. This method is wrapper to
138          * isEmpty()
139          *
140          * @return Whether the basket is empty
141          */
142         public boolean hasItems ();
143
144         /**
145          * Checks whether the basket is empty
146          *
147          * @return Whether the basket is empty
148          */
149         public boolean isEmpty ();
150
151         /**
152          * Checks whether the currently set product is added in basked
153          *
154          * @param product Product instance
155          * @return Whether the product is added
156          */
157         public boolean isProductAdded (final Product product);
158
159         /**
160          * Outputs last added item in the basket.
161          *
162          * @return Last added item
163          */
164         public String outputLastAddedItem ();
165 }