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 * Checks whether the basket is empty
34 * @return Whether the basket is empty
36 public boolean isEmpty ();
39 * Checks whether the basket has items in it. This method is wrapper to
42 * @return Whether the basket is empty
44 public boolean hasItems ();
47 * Checks whether the currently set product is added in basked
49 * @param product Product instance
50 * @return Whether the product is added
52 public boolean isProductAdded (final Product product);
55 * Adds given product instance to basket by adding amount from form data to
58 * @param product Product instance to add
59 * @return Redirect target or null
61 public String addItem (final Product product);
64 * Getter for item amount property
66 * @return Item amount property
68 public Long getAmount ();
71 * Setter for item amount property
73 * @param amount Item amount property
75 public void setAmount (final Long amount);
78 * Getter for current item
80 * @return Current item
82 public AddableBasketItem getCurrentItem ();
85 * Setter for current item
87 * @param currentItem Current item
89 public void setCurrentItem (final AddableBasketItem currentItem);
92 * Calculates total price (no tax added) of current item. If no current item
93 * is set and no amount, a NPE is thrown.
95 * @return Current item's total price
97 public Float calculateCurrentItemPrice ();
100 * Calculates total price (no tax added) for given item.
102 * @param item Item instance to calculate total price for
103 * @return Total price
105 public Float calculateItemPrice (final AddableBasketItem item);
108 * Getter for last entry
110 * @return Last added item in basket
112 public AddableBasketItem getLast ();
115 * Getter for last num rows
117 * @return Last num rows
119 public int getLastNumRows ();
122 * Gets for all added items
124 * @return A list of all added items
126 public List<AddableBasketItem> allItems ();