Class DefaultRegistryImpl<C>

  • All Implemented Interfaces:
    DefaultRegistry<C>, Registry<C>

    public class DefaultRegistryImpl<C>
    extends Object
    implements DefaultRegistry<C>
    The default generic implementation for the Registry type. 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 Detail

      • DefaultRegistryImpl

        public DefaultRegistryImpl()
    • Method Detail

      • setMaxSize

        public void setMaxSize​(int size)
        Description copied from interface: Registry
        Sets the max number of items that can be stored on the registry.
        Specified by:
        setMaxSize in interface Registry<C>
        Parameters:
        size - A positive integer
      • register

        public void register​(C item)
        Description copied from interface: Registry
        Registers an item into the registry
        Specified by:
        register in interface Registry<C>
        Parameters:
        item - An item to register
      • clear

        public void clear()
        Description copied from interface: Registry
        Clears the registry
        Specified by:
        clear in interface Registry<C>
      • getHistory

        public List<C> getHistory()
        Description copied from interface: Registry
        Returns a List containing all the items in the registry
        Specified by:
        getHistory in interface Registry<C>
        Returns:
        A List of containing the registered items
      • peek

        public C peek()
        Description copied from interface: Registry
        Peeks the last added item. Doesn't remove it.
        Specified by:
        peek in interface Registry<C>
        Returns:
        The last added item
      • pop

        public C pop()
        Description copied from interface: Registry
        Pops the last added item and removes it.
        Specified by:
        pop in interface Registry<C>
        Returns:
        The last added item
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Registry
        Determines if the registry is empty or not
        Specified by:
        isEmpty in interface Registry<C>
        Returns:
        true if empty, false if not.