SalesPoint Framework v3.1

data
Interface CountingStock

All Superinterfaces:
Cloneable, Comparable, DataBasketEntryDestination, DataBasketEntrySource, Nameable, Serializable, Stock, StockItem
All Known Subinterfaces:
MoneyBag
All Known Implementing Classes:
CountingStockFilter, CountingStockImpl, MoneyBagFilter, MoneyBagImpl

public interface CountingStock
extends Stock

A Stock that counts for each CatalogItem in the associated Catalog how many objects of that type are actually available.

In contrast to StoringStocks, the StockItems for the same key have no differences when using CountingStocks. Therefore, only two pieces of information are needed: the key and the number of items for that key.

CountingStocks are by far the more common type of Stock.

Since:
v2.0
Author:
Steffen Zschaler

Field Summary
 
Fields inherited from interface data.Nameable
NAME_PROPERTY
 
Method Summary
 void add(String sKey, int nCount, DataBasket db)
          Add a number of items of a given key to the Stock.
 void remove(String sKey, int nCount, DataBasket db)
          Remove a number of items of a given key from the Stock.
 
Methods inherited from interface data.Stock
add, addStock, contains, contains, containsStock, countItems, fillStockWithValue, get, getCatalog, iterator, keySet, remove, remove, size, sumStock
 
Methods inherited from interface data.StockItem
clone, getAssociatedItem, getStock
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface data.Nameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 

Method Detail

add

public void add(String sKey,
                int nCount,
                DataBasket db)
Add a number of items of a given key to the Stock.

As with any Stock the added items will not at once be visible to users of other DataBaskets.

In general the method behaves as though it would call Stock.add(data.StockItem, data.DataBasket) nCount times. Especially, the same exceptions might occur and the same constraints hold.

Parameters:
sKey - the key for which to add a number of items.
nCount - how many items are to be added?
db - the DataBasket relative to which the adding is performed.
Throws:
IllegalArgumentException - if nCount <= 0.
CatalogConflictException - if the key cannot be found in the Catalog.
Override:
Always

remove

public void remove(String sKey,
                   int nCount,
                   DataBasket db)
            throws VetoException
Remove a number of items of a given key from the Stock.

In general the method behaves as though it would call Stock.remove(java.lang.String, data.DataBasket) nCount times. Especially, the same exceptions might occur and the same constraints hold.

Parameters:
sKey - the key for which to remove a number of items.
nCount - how many items are to be removed?
db - the DataBasket relative to which the removal is performed.
Throws:
VetoException - if a listener vetos the removal.
NotEnoughElementsException - if there are not enough elements to fulfill the request. If this exception is thrown no items will have been removed.
IllegalArgumentException - if nCount <= 0
Override:
Always

SalesPoint Framework v3.1