Package com.metratec.lib.inventory
Class Inventory<T extends RfidTag>
- java.lang.Object
-
- com.metratec.lib.inventory.Inventory<T>
-
- Type Parameters:
T
-RfidTag
instance
public class Inventory<T extends RfidTag> extends java.lang.Object
Inventory which can throw events.
First create the inventory and than start it withstart()
. Then you cann add tags withupdateInventory(Collection)
. The inventory object will call theInventoryListener.tagArrive(TagArrivedEvent)
method if new tags are foundInventoryListener.tagDeparted(TagDepartedEvent)
method if tags are lostInventoryListener.inventoryChanged(InventoryChangedEvent)
method if the inventory is changed.
- Author:
- man
-
-
Constructor Summary
Constructors Constructor Description Inventory(java.lang.String identifier)
Create a new inventoryInventory(java.lang.String identifier, InventoryListener<T> listener)
Create a new inventoryInventory(java.lang.String identifier, InventoryListener<T> listener, long tagKeepTime)
Create a new inventory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTag(T tag)
void
clear()
Remove all tags from the inventoryjava.util.List<T>
getInventory()
Return aList
with the current inventorylong
getKeepTime()
void
initInventory(java.util.List<T> inventory)
initialise the inventoryboolean
isAlive()
boolean
isSticky()
void
removeTag(java.lang.String tagEid)
Remove a tag from this listvoid
removeTag(T tag)
void
setKeepTime(long keepTime)
void
start()
start automatically checking the inventory for lost tagsvoid
stop()
stop automatically checking tagsvoid
updateInventory(java.util.Collection<T> inventory)
update the current inventory
-
-
-
Constructor Detail
-
Inventory
public Inventory(java.lang.String identifier)
Create a new inventory- Parameters:
identifier
- inventory identifier
-
Inventory
public Inventory(java.lang.String identifier, InventoryListener<T> listener)
Create a new inventory- Parameters:
identifier
- inventory identifierlistener
- the listener
-
Inventory
public Inventory(java.lang.String identifier, InventoryListener<T> listener, long tagKeepTime)
Create a new inventory- Parameters:
identifier
- inventory identifierlistener
- the listenertagKeepTime
- the tag keep time (to disable automatic removing tags, set keep time to 0)
-
-
Method Detail
-
initInventory
public void initInventory(java.util.List<T> inventory)
initialise the inventory- Parameters:
inventory
- tags
-
updateInventory
public void updateInventory(java.util.Collection<T> inventory)
update the current inventory- Parameters:
inventory
-Collection
with the tag ids
-
addTag
public void addTag(T tag)
-
removeTag
public void removeTag(T tag)
-
getInventory
public java.util.List<T> getInventory()
Return aList
with the current inventory- Returns:
- a
List
with the current inventory
-
getKeepTime
public long getKeepTime()
- Returns:
- the current tag keep time
-
setKeepTime
public void setKeepTime(long keepTime)
- Parameters:
keepTime
- the tag keep time to set
-
start
public void start()
start automatically checking the inventory for lost tags
-
stop
public void stop()
stop automatically checking tags
-
isSticky
public boolean isSticky()
- Returns:
- the isSticky
-
removeTag
public void removeTag(java.lang.String tagEid)
Remove a tag from this list- Parameters:
tagEid
- tag eid to remove
-
clear
public void clear()
Remove all tags from the inventory
-
isAlive
public boolean isAlive()
- Returns:
- true if the inventory checking thread is alive
-
-