com.elasticpath.domain.shoppingcart.impl
Class AbstractCartItemImpl

java.lang.Object
  extended by com.elasticpath.domain.impl.AbstractEpDomainImpl
      extended by com.elasticpath.domain.impl.AbstractPersistenceImpl
          extended by com.elasticpath.domain.impl.AbstractValueObjectImpl
              extended by com.elasticpath.domain.shoppingcart.impl.AbstractCartItemImpl
All Implemented Interfaces:
EpDomain, Persistence, CartItem, ValueObject, java.io.Serializable
Direct Known Subclasses:
ShoppingCartItemImpl, WishListItemImpl

public abstract class AbstractCartItemImpl
extends AbstractValueObjectImpl
implements CartItem

A CartItem represents a quantity of SKUs in a shopping cart, saved cart, wish list, etc.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Serial version id.
 
Constructor Summary
AbstractCartItemImpl()
           
 
Method Summary
 void addDependentCartItem(CartItem dependentCartItem)
          Specify that another cart item depends on this cart item.
 void applyDiscount(java.math.BigDecimal amount)
          Adds a discount amount to this cart item.
 void clearDiscount()
          Removes previously applied CartItem discounts.
 java.math.BigDecimal getAmount(java.util.Currency currency)
          Get the total price of this shopping cart item.
 Money getAmountMoney(java.util.Currency currency)
          Get the amount as a Money object.
 java.util.Set getDependentCartItems()
          Get the set of dependent cart items.
 CartItem getParentCartItem()
          Get the parent cart item that this cart item is dependent on.
 ProductSku getProductSku()
          Get the product SKU corresponding to this item in a cart.
 int getQuantity()
          Get the quantity of this item as a primitive int.
 java.lang.String getType()
          Get the type of this cart item.
 boolean hasDependentCartItem(java.lang.String skuCode)
          Returns true if this CartItem has another cart items that depend on it which matches the supplied skuCode.
 boolean hasDependentCartItems()
          Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.
 boolean hasSufficientInventory()
          Returns true if there is sufficent stock to sell this cart item (in the quantity set in the CartItem).
 boolean isDependent()
          Returns true if this CartItem depends on another cart item such that it can't exist in the cart on its own.
 void setDependentCartItems(java.util.Set dependentCartItems)
          Set the set of dependent cart items.
 void setParentCartItem(CartItem parentCartItem)
          Set the parent cart item that this cart item is dependent on.
 void setProductSku(ProductSku productSku)
          Set the product SKU corresponding to this item in a cart.
 void setQuantity(int quantity)
          Set the quantity of this item as a primitive int.
 void setType(java.lang.String type)
          Set the type of element.
 
Methods inherited from class com.elasticpath.domain.impl.AbstractPersistenceImpl
executeBeforePersistAction, getUidPk, isPersistent, setDefaultValues, setUidPk
 
Methods inherited from class com.elasticpath.domain.impl.AbstractEpDomainImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.domain.Persistence
executeBeforePersistAction, getUidPk, isPersistent, setDefaultValues, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Serial version id.

See Also:
Constant Field Values
Constructor Detail

AbstractCartItemImpl

public AbstractCartItemImpl()
Method Detail

addDependentCartItem

public void addDependentCartItem(CartItem dependentCartItem)
Specify that another cart item depends on this cart item.

Specified by:
addDependentCartItem in interface CartItem
Parameters:
dependentCartItem - the other, dependent cart item

applyDiscount

public void applyDiscount(java.math.BigDecimal amount)
Adds a discount amount to this cart item. This will be subtracted from the amount of the CartItem and each invocation adds to the discount.

Specified by:
applyDiscount in interface CartItem
Parameters:
amount - the amount to discount

clearDiscount

public void clearDiscount()
Removes previously applied CartItem discounts.

Specified by:
clearDiscount in interface CartItem

getAmount

public java.math.BigDecimal getAmount(java.util.Currency currency)
Get the total price of this shopping cart item. The total price is the price * quantity - discount. The sale price is used in the calculation.

Specified by:
getAmount in interface CartItem
Parameters:
currency - the currency of the total price to be returned
Returns:
a BigDecimal object representing the total price

getAmountMoney

public Money getAmountMoney(java.util.Currency currency)
Get the amount as a Money object.

Specified by:
getAmountMoney in interface CartItem
Parameters:
currency - the currency of the total price to be returned
Returns:
a Money object representing the total price

getDependentCartItems

public java.util.Set getDependentCartItems()
Get the set of dependent cart items.

Specified by:
getDependentCartItems in interface CartItem
Returns:
the set of dependent cart items.

getParentCartItem

public CartItem getParentCartItem()
Get the parent cart item that this cart item is dependent on. Returns null if this cart item does not depend on another.

Specified by:
getParentCartItem in interface CartItem
Returns:
the parent cart item or null if there is no parent.

getProductSku

public ProductSku getProductSku()
Get the product SKU corresponding to this item in a cart.

Specified by:
getProductSku in interface CartItem
Returns:
a ProductSKU

getQuantity

public int getQuantity()
Get the quantity of this item as a primitive int. Required by Spring Validatr.

Specified by:
getQuantity in interface CartItem
Returns:
the quantity

getType

public java.lang.String getType()
Get the type of this cart item. (e.g. cartItem or wishListItem. Should match spring bean factory bean id.)

Specified by:
getType in interface CartItem
Returns:
the type

hasDependentCartItem

public boolean hasDependentCartItem(java.lang.String skuCode)
Returns true if this CartItem has another cart items that depend on it which matches the supplied skuCode.

Specified by:
hasDependentCartItem in interface CartItem
Parameters:
skuCode - The GUID of the particular dependant SKU to be in the cart.
Returns:
true if this CartItem has a depenant item that matches the supplied skuCode

hasDependentCartItems

public boolean hasDependentCartItems()
Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.

Specified by:
hasDependentCartItems in interface CartItem
Returns:
true if this CartItem has other cart items that depend on it.

hasSufficientInventory

public boolean hasSufficientInventory()
Returns true if there is sufficent stock to sell this cart item (in the quantity set in the CartItem).

Specified by:
hasSufficientInventory in interface CartItem
Returns:
true if there is sufficient stock

isDependent

public boolean isDependent()
Returns true if this CartItem depends on another cart item such that it can't exist in the cart on its own.

Specified by:
isDependent in interface CartItem
Returns:
true if this CartItem depends on another cart item.

setDependentCartItems

public void setDependentCartItems(java.util.Set dependentCartItems)
Set the set of dependent cart items.

Specified by:
setDependentCartItems in interface CartItem
Parameters:
dependentCartItems - the set of dependent cart items.

setParentCartItem

public void setParentCartItem(CartItem parentCartItem)
Set the parent cart item that this cart item is dependent on.

Specified by:
setParentCartItem in interface CartItem
Parameters:
parentCartItem - the parent cart item.

setProductSku

public void setProductSku(ProductSku productSku)
Set the product SKU corresponding to this item in a cart.

Specified by:
setProductSku in interface CartItem
Parameters:
productSku - the ProductSKU

setQuantity

public void setQuantity(int quantity)
Set the quantity of this item as a primitive int. Required by Spring Validator.

Specified by:
setQuantity in interface CartItem
Parameters:
quantity - the quantity

setType

public void setType(java.lang.String type)
Set the type of element. (e.g. cartItem or wishListItem. Should match bean name)

Specified by:
setType in interface CartItem
Parameters:
type - the type of cart item