2 * Copyright (C) 2015 Roland Haeder
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.
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.
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/>.
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 BasketWebController extends Serializable {
32 * Clears this basket instance
37 * Checks whether the basket is empty
39 * @return Whether the basket is empty
41 public boolean isEmpty ();
44 * Checks whether the basket has items in it. This method is wrapper to
47 * @return Whether the basket is empty
49 public boolean hasItems ();
52 * Checks whether the currently set product is added in basked
54 * @param product Product instance
55 * @return Whether the product is added
57 public boolean isProductAdded (final Product product);
60 * Adds given product instance to basket by adding amount from form data to
63 * @param product Product instance to add
64 * @return Redirect target or null
66 public String addItem (final Product product);
69 * Getter for item amount property
71 * @return Item amount property
73 public Long getAmount ();
76 * Setter for item amount property
78 * @param amount Item amount property
80 public void setAmount (final Long amount);
83 * Getter for current item
85 * @return Current item
87 public AddableBasketItem getCurrentItem ();
90 * Setter for current item
92 * @param currentItem Current item
94 public void setCurrentItem (final AddableBasketItem currentItem);
97 * Calculates total price (no tax added) of current item. If no current item
98 * is set and no amount, a NPE is thrown.
100 * @return Current item's total price
102 public Float calculateCurrentItemPrice ();
105 * Calculates total price (no tax added) for given item.
107 * @param item Item instance to calculate total price for
108 * @return Total price
110 public Float calculateItemPrice (final AddableBasketItem item);
113 * Calculates total sum (no tax added) for all items
115 * @return Total price of all items
117 public Float calculateTotalPrice ();
120 * Getter for last entry
122 * @return Last added item in basket
124 public AddableBasketItem getLast ();
127 * Getter for last num rows
129 * @return Last num rows
131 public int getLastNumRows ();
134 * Gets for all added items
136 * @return A list of all added items
138 public List<AddableBasketItem> allItems ();
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
145 * @param product Product instance
146 * @return Item amount of given product
148 public Long getItemAmount (final Product product);
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.
154 * @param item Item instance to change
155 * @return Page redirection
157 public String changeItem (final AddableBasketItem item);
160 * Outputs last added item in the basket.
162 * @return Last added item
164 public String outputLastAddedItem();