]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionController.java
renamed files to make difference to other war-projects
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / basket / PizzaBasketWebSessionController.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (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 Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero 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  * <p>
27  * @author Roland Haeder<roland@mxchange.org>
28  */
29 public interface PizzaBasketWebSessionController extends Serializable {
30
31         /**
32          * Adds given product instance to basket by adding amount from form data to
33          * it.
34          * <p>
35          * @param product Product instance to add
36          * <p>
37          * @return Redirect target or null
38          */
39         String addItem (final Product product);
40
41         /**
42          * Gets for all added items
43          * <p>
44          * @return A list of all added items
45          */
46         List<AddableBasketItem> allItems ();
47
48         /**
49          * Calculates total price (no tax added) of current item. If no current item
50          * is set and no amount, a NPE is thrown.
51          * <p>
52          * @return Current item's total price
53          */
54         Float calculateCurrentItemPrice ();
55
56         /**
57          * Calculates total price (no tax added) for given item.
58          * <p>
59          * @param item Item instance to calculate total price for
60          * <p>
61          * @return Total price
62          */
63         Float calculateItemPrice (final AddableBasketItem item);
64
65         /**
66          * Calculates total sum (no tax added) for all items
67          * <p>
68          * @return Total price of all items
69          */
70         Float calculateTotalPrice ();
71
72         /**
73          * Changes given item instance's amount in basket and redirects to proper
74          * page. If the item is not found, another "error" page is called.
75          * <p>
76          * @param item Item instance to change
77          * <p>
78          * @return Page redirection
79          */
80         String doChangeItem (final AddableBasketItem item);
81
82         /**
83          * Clears this basket instance
84          */
85         void clear ();
86
87         /**
88          * Getter for item amount property
89          * <p>
90          * @return Item amount property
91          */
92         Long getOrderedAmount ();
93
94         /**
95          * Setter for item amount property
96          * <p>
97          * @param amount Item amount property
98          */
99         void setOrderedAmount (final Long amount);
100
101         /**
102          * Getter for current item
103          * <p>
104          * @return Current item
105          */
106         AddableBasketItem getCurrentItem ();
107
108         /**
109          * Setter for current item
110          * <p>
111          * @param currentItem Current item
112          */
113         void setCurrentItem (final AddableBasketItem currentItem);
114
115         /**
116          * Some getter for item amount of given product. This method requires a full
117          * iteration over all items in the basket to look for proper product
118          * instance.
119          * <p>
120          * @param product Product instance
121          * <p>
122          * @return Item amount of given product
123          */
124         Long getItemAmount (final Product product);
125
126         /**
127          * Getter for last entry
128          * <p>
129          * @return Last added item in basket
130          */
131         AddableBasketItem getLast ();
132
133         /**
134          * Getter for last num rows
135          * <p>
136          * @return Last num rows
137          */
138         int getLastNumRows ();
139
140         /**
141          * Checks whether the basket has items in it. This method is wrapper to
142          * isEmpty()
143          * <p>
144          * @return Whether the basket is empty
145          */
146         boolean hasItems ();
147
148         /**
149          * Checks whether the basket is empty
150          * <p>
151          * @return Whether the basket is empty
152          */
153         boolean isEmpty ();
154
155         /**
156          * Checks whether the currently set product is added in basked
157          * <p>
158          * @param product Product instance
159          * <p>
160          * @return Whether the product is added
161          */
162         boolean isProductAdded (final Product product);
163
164         /**
165          * Outputs last added item in the basket.
166          * <p>
167          * @return Last added item
168          */
169         String outputLastAddedItem ();
170 }