2 * Copyright (C) 2016 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.pizzaapplication.beans.basket;
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;
25 * An interface for a basket
27 * @author Roland Haeder<roland@mxchange.org>
29 public interface PizzaBasketWebSessionController extends Serializable {
32 * Adds given product instance to basket by adding amount from form data to
35 * @param product Product instance to add
37 * @return Redirect target or null
39 String addItem (final Product product);
42 * Gets for all added items
44 * @return A list of all added items
46 List<AddableBasketItem> allItems ();
49 * Calculates total price (no tax added) of current item. If no current item
50 * is set and no amount, a NPE is thrown.
52 * @return Current item's total price
54 Float calculateCurrentItemPrice ();
57 * Calculates total price (no tax added) for given item.
59 * @param item Item instance to calculate total price for
63 Float calculateItemPrice (final AddableBasketItem item);
66 * Calculates total sum (no tax added) for all items
68 * @return Total price of all items
70 Float calculateTotalPrice ();
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.
76 * @param item Item instance to change
78 * @return Page redirection
80 String doChangeItem (final AddableBasketItem item);
83 * Clears this basket instance
88 * Getter for item amount property
90 * @return Item amount property
92 Long getOrderedAmount ();
95 * Setter for item amount property
97 * @param amount Item amount property
99 void setOrderedAmount (final Long amount);
102 * Getter for current item
104 * @return Current item
106 AddableBasketItem getCurrentItem ();
109 * Setter for current item
111 * @param currentItem Current item
113 void setCurrentItem (final AddableBasketItem currentItem);
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
120 * @param product Product instance
122 * @return Item amount of given product
124 Long getItemAmount (final Product product);
127 * Getter for last entry
129 * @return Last added item in basket
131 AddableBasketItem getLast ();
134 * Getter for last num rows
136 * @return Last num rows
138 int getLastNumRows ();
141 * Checks whether the basket has items in it. This method is wrapper to
144 * @return Whether the basket is empty
149 * Checks whether the basket is empty
151 * @return Whether the basket is empty
156 * Checks whether the currently set product is added in basked
158 * @param product Product instance
160 * @return Whether the product is added
162 boolean isProductAdded (final Product product);
165 * Outputs last added item in the basket.
167 * @return Last added item
169 String outputLastAddedItem ();