Class InventoryItem<T extends InventoryItem<T>>
- java.lang.Object
-
- org.salespointframework.core.AbstractEntity<InventoryItemIdentifier>
-
- org.salespointframework.inventory.InventoryItem<T>
-
- All Implemented Interfaces:
org.springframework.data.domain.Persistable<InventoryItemIdentifier>
- Direct Known Subclasses:
MultiInventoryItem,UniqueInventoryItem
@MappedSuperclass public abstract class InventoryItem<T extends InventoryItem<T>> extends AbstractEntity<InventoryItemIdentifier>
AnInventoryItemassociates a product with aQuantityto keep track of how many items per product are available.- Since:
- 7.2
- Author:
- Paul Henke, Oliver Drotbohm, Martin Morgenstern
- See Also:
UniqueInventoryItem,MultiInventoryItem
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedInventoryItem()protectedInventoryItem(Product product, Quantity quantity)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TdecreaseQuantity(Quantity quantity)Decreases the quantity of the currentInventoryItemby the givenQuantity.InventoryItemIdentifiergetId()protected abstract ProductgetProduct()QuantitygetQuantity()booleanhasSufficientQuantity(Quantity quantity)Returns whether theInventoryItemis available in exactly or more of the given quantity.TincreaseQuantity(Quantity quantity)Increases the quantity of the currentInventoryItemby the givenQuantity.booleankeepsTrackOf(Product product)Returns whether theInventoryItembelongs to the givenProduct.StringtoString()-
Methods inherited from class org.salespointframework.core.AbstractEntity
equals, hashCode, isNew
-
-
-
-
Constructor Detail
-
InventoryItem
protected InventoryItem(Product product, Quantity quantity)
- Parameters:
quantity- the initialQuantityfor thisInventoryItem, must not be null.
-
InventoryItem
protected InventoryItem()
-
-
Method Detail
-
getId
public final InventoryItemIdentifier getId()
-
hasSufficientQuantity
public boolean hasSufficientQuantity(Quantity quantity)
Returns whether theInventoryItemis available in exactly or more of the given quantity.- Parameters:
quantity- must not be null.- Returns:
-
decreaseQuantity
public T decreaseQuantity(Quantity quantity)
Decreases the quantity of the currentInventoryItemby the givenQuantity.- Parameters:
quantity- must not be null.
-
increaseQuantity
public T increaseQuantity(Quantity quantity)
Increases the quantity of the currentInventoryItemby the givenQuantity.- Parameters:
quantity- must not be null.
-
keepsTrackOf
public boolean keepsTrackOf(Product product)
Returns whether theInventoryItembelongs to the givenProduct.- Parameters:
product- must not be null.- Returns:
-
getProduct
protected abstract Product getProduct()
-
getQuantity
public Quantity getQuantity()
-
-