Class InventoryItem<T extends InventoryItem<T>>

All Implemented Interfaces:
Persistable<InventoryItem.InventoryItemIdentifier>
Direct Known Subclasses:
MultiInventoryItem, UniqueInventoryItem

@MappedSuperclass public abstract class InventoryItem<T extends InventoryItem<T>> extends AbstractAggregateRoot<InventoryItem.InventoryItemIdentifier>
An InventoryItem associates a product with a Quantity to keep track of how many items per product are available.
Since:
7.2
Author:
Paul Henke, Oliver Drotbohm, Martin Morgenstern
See Also:
  • Constructor Details

  • Method Details

    • getId

    • hasSufficientQuantity

      public boolean hasSufficientQuantity(Quantity quantity)
      Returns whether the InventoryItem 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 current InventoryItem by the given Quantity.
      Parameters:
      quantity - must not be null.
    • increaseQuantity

      public T increaseQuantity(Quantity quantity)
      Increases the quantity of the current InventoryItem by the given Quantity.
      Parameters:
      quantity - must not be null.
    • keepsTrackOf

      public boolean keepsTrackOf(Product product)
      Returns whether the InventoryItem belongs to the given Product.
      Parameters:
      product - must not be null.
      Returns:
    • getProduct

      protected abstract Product getProduct()
      Returns the Product this InventoryItem belongs to.
      Returns:
      must not be null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getQuantity

      public Quantity getQuantity()