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>
AnInventoryItem
associates a product with aQuantity
to 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 protected
InventoryItem()
protected
InventoryItem(Product product, Quantity quantity)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
decreaseQuantity(Quantity quantity)
Decreases the quantity of the currentInventoryItem
by the givenQuantity
.InventoryItemIdentifier
getId()
protected abstract Product
getProduct()
Quantity
getQuantity()
boolean
hasSufficientQuantity(Quantity quantity)
Returns whether theInventoryItem
is available in exactly or more of the given quantity.T
increaseQuantity(Quantity quantity)
Increases the quantity of the currentInventoryItem
by the givenQuantity
.boolean
keepsTrackOf(Product product)
Returns whether theInventoryItem
belongs to the givenProduct
.String
toString()
-
Methods inherited from class org.salespointframework.core.AbstractEntity
equals, hashCode, isNew
-
-
-
-
Constructor Detail
-
InventoryItem
protected InventoryItem(Product product, Quantity quantity)
- Parameters:
quantity
- the initialQuantity
for thisInventoryItem
, must not be null.
-
InventoryItem
protected InventoryItem()
-
-
Method Detail
-
getId
public final InventoryItemIdentifier getId()
-
hasSufficientQuantity
public boolean hasSufficientQuantity(Quantity quantity)
Returns whether theInventoryItem
is 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 currentInventoryItem
by the givenQuantity
.- Parameters:
quantity
- must not be null.
-
increaseQuantity
public T increaseQuantity(Quantity quantity)
Increases the quantity of the currentInventoryItem
by the givenQuantity
.- Parameters:
quantity
- must not be null.
-
keepsTrackOf
public boolean keepsTrackOf(Product product)
Returns whether theInventoryItem
belongs to the givenProduct
.- Parameters:
product
- must not be null.- Returns:
-
getProduct
protected abstract Product getProduct()
-
getQuantity
public Quantity getQuantity()
-
-