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