Class DefaultRegistryImpl<C>
- java.lang.Object
-
- org.appformer.client.stateControl.registry.impl.DefaultRegistryImpl<C>
-
- All Implemented Interfaces:
DefaultRegistry<C>,Registry<C>
public class DefaultRegistryImpl<C> extends Object implements DefaultRegistry<C>
The default generic implementation for theRegistrytype. It's implemented for achieving an in-memory and lightweight registry approach, don't do an overuse of it. Note: The Stack class behavior when using the iterator is not the expected one, so used ArrayDeque instead of an Stack to provide right iteration order.
-
-
Constructor Summary
Constructors Constructor Description DefaultRegistryImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the registryList<C>getHistory()Returns aListcontaining all the items in the registrybooleanisEmpty()Determines if the registry is empty or notCpeek()Peeks the last added item.Cpop()Pops the last added item and removes it.voidregister(C item)Registers an item into the registryvoidsetMaxSize(int size)Sets the max number of items that can be stored on the registry.voidsetRegistryChangeListener(RegistryChangeListener registryChangeListener)Sets aRegistryChangeListenerto be called when the registry changes.
-
-
-
Method Detail
-
setMaxSize
public void setMaxSize(int size)
Description copied from interface:RegistrySets the max number of items that can be stored on the registry.- Specified by:
setMaxSizein interfaceRegistry<C>- Parameters:
size- A positive integer
-
register
public void register(C item)
Description copied from interface:RegistryRegisters an item into the registry
-
clear
public void clear()
Description copied from interface:RegistryClears the registry
-
getHistory
public List<C> getHistory()
Description copied from interface:RegistryReturns aListcontaining all the items in the registry- Specified by:
getHistoryin interfaceRegistry<C>- Returns:
- A
Listof containing the registered items
-
setRegistryChangeListener
public void setRegistryChangeListener(RegistryChangeListener registryChangeListener)
Description copied from interface:RegistrySets aRegistryChangeListenerto be called when the registry changes.- Specified by:
setRegistryChangeListenerin interfaceRegistry<C>- Parameters:
registryChangeListener- ARegistryChangeListener
-
peek
public C peek()
Description copied from interface:RegistryPeeks the last added item. Doesn't remove it.
-
pop
public C pop()
Description copied from interface:RegistryPops the last added item and removes it.
-
-