Package org.salespointframework.order
Class Cart
java.lang.Object
org.salespointframework.order.Cart
Abstraction of a shopping cart.
- Author:
- Paul Henke, Oliver Gierke
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddItemsTo(Order order) Adds all items currently contained in this cart to the givenOrder.addOrUpdateItem(Product product, double amount) addOrUpdateItem(Product product, long amount) addOrUpdateItem(Product product, Quantity quantity) voidclear()Clears the cart.createOrderFor(UserAccount user) Creates a new Order for the givenUserAccountfrom the currentCart.Returns the CartItem for the given identifier.intReturns the number of items currently in the cart.javax.money.MonetaryAmountgetPrice()getQuantity(Product product) getQuantity(Product.ProductIdentifier identifier) Returns the quantity for the givenProduct.ProductIdentifiercurrently contained in theCart.booleanisEmpty()Returns whether theCartis currently empty.iterator()voidremoveItem(String identifier) Removes theCartItemwith the given identifier.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Cart
public Cart()
-
-
Method Details
-
addOrUpdateItem
-
addOrUpdateItem
-
addOrUpdateItem
-
removeItem
Removes theCartItemwith the given identifier.- Parameters:
identifier- must not be null.
-
getItem
Returns the CartItem for the given identifier.- Parameters:
identifier- must not be null.- Returns:
-
clear
public void clear()Clears the cart. -
isEmpty
public boolean isEmpty()Returns whether theCartis currently empty.- Specified by:
isEmptyin interfaceStreamable<CartItem>- Returns:
-
addItemsTo
Adds all items currently contained in this cart to the givenOrder.- Parameters:
order- must not be null.- Returns:
- the
Orderwith the added items of this cart - Throws:
IllegalStateException- if the given Order is notOrderStatus.OPENanymore.
-
createOrderFor
Creates a new Order for the givenUserAccountfrom the currentCart.- Parameters:
user- must not be null.- Returns:
- a new Order for the current
Cartand givenUserAccount.
-
getNumberOfItems
public int getNumberOfItems()Returns the number of items currently in the cart. Sums up the containedProduct's units defaulting to a single unit in case theProductis not handled in units.- Returns:
- will never be null.
- Since:
- 7.5
- See Also:
-
getQuantity
- Parameters:
product- must not be null.- Returns:
- will never be null.
- Since:
- 7.5
-
getQuantity
Returns the quantity for the givenProduct.ProductIdentifiercurrently contained in theCart.- Parameters:
identifier- must not be null.- Returns:
- will never be null.
- Since:
- 7.5
-
getPrice
public javax.money.MonetaryAmount getPrice() -
iterator
-