Constructor and Description |
---|
Cart() |
Modifier and Type | Method and Description |
---|---|
void |
addItemsTo(Order order)
Turns the current state of the cart into an
Order . |
CartItem |
addOrUpdateItem(Product product,
Quantity quantity)
|
void |
clear()
Clears the cart.
|
Optional<CartItem> |
getItem(String identifier)
Returns the CartItem for the given identifier.
|
org.joda.money.Money |
getPrice()
Returns the proce of the item.
|
boolean |
isEmpty()
Returns whether the
Cart is currently empty. |
Iterator<CartItem> |
iterator() |
Optional<CartItem> |
removeItem(String identifier)
Removes the
CartItem with the given identifier. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public CartItem addOrUpdateItem(Product product, Quantity quantity)
CartItem
for the given Product
and Quantity
. If a CartItem
for the given
Product
already exists the Cart
will be updated to reflect the combined Quantity
for the
backing CartItem
.product
- must not be nullquantity
- must not be nullCartItem
.public Optional<CartItem> removeItem(String identifier)
CartItem
with the given identifier.identifier
- must not be null.public Optional<CartItem> getItem(String identifier)
identifier
- must not be null.public void clear()
public boolean isEmpty()
Cart
is currently empty.public void addItemsTo(Order order)
Order
.order
- must not be null.IllegalStateException
- if the given Order is not OrderStatus.OPEN
anymore.public org.joda.money.Money getPrice()
Priced
Copyright © 2014 Pivotal Software, Inc.. All rights reserved.