public abstract class ProductAmountListOwner
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<ProductAmount> |
productAmountList |
Constructor and Description |
---|
ProductAmountListOwner(java.util.List<ProductAmount> productAmountList)
Constructor that creates a productAmountList from all the given ProductAmounts,
and handles the situation when there are 2 productAmounts with the same product
|
Modifier and Type | Method and Description |
---|---|
void |
addProductAmount(ProductAmount newProductAmount)
Adds the product to the list.
|
void |
addProductOrIncreaseAmount(ProductAmount productAmount)
Tries to insert an item in the list.
|
ProductAmount |
getProductAmountByProductName(java.lang.String name)
Search and return a product in the productAmountList list.
|
protected java.util.List<ProductAmount> |
getUnderlyingProductAmountList()
Returns a direct reference to the product amount list (not a copy).
|
boolean |
isEmpty() |
void |
setUnderlyingProductAmountList(java.util.List<ProductAmount> productAmountList)
Only used for testing purposes
|
private java.util.List<ProductAmount> productAmountList
public ProductAmountListOwner(java.util.List<ProductAmount> productAmountList)
productAmountList
- protected java.util.List<ProductAmount> getUnderlyingProductAmountList()
public void setUnderlyingProductAmountList(java.util.List<ProductAmount> productAmountList)
productAmountList
- public final void addProductAmount(ProductAmount newProductAmount) throws InvalidProductAmountException
newProductAmount
- InvalidProductAmountException
public final void addProductOrIncreaseAmount(ProductAmount productAmount)
productAmount
- public ProductAmount getProductAmountByProductName(java.lang.String name)
name
- the name of the productpublic boolean isEmpty()