Class AbstractUpdateQueue<T>

  • All Implemented Interfaces:
    UpdateQueue<T>, java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Long,​T>, java.util.NavigableMap<java.lang.Long,​T>, java.util.SortedMap<java.lang.Long,​T>
    Direct Known Subclasses:
    OrderStatusUpdateQueue, ProductExpressUpdateQueue

    public abstract class AbstractUpdateQueue<T>
    extends java.util.TreeMap<java.lang.Long,​T>
    implements UpdateQueue<T>
    Abstract implementation of UpdateQueue using TreeMap for storing elements WARNING: this queue has limited capacity due to its in-memory nature
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int DEFAULT_MAX_CAPACITY  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addItem​(T item)
      Adds item to the queue
      void addItems​(java.util.List<T> items)
      Adds all elements from the list to the queue
      java.util.List<T> getItems()
      Returns all elements in the queue.
      java.util.List<T> getItems​(java.util.Date newerThan)
      Returns all elements in the queue newer than a specific day
      T getLastItem()
      Returns last item from the queue
      int getMaxCapacity()  
      protected java.lang.Long getTimeKey​(T item)  
      void removeItems()
      Removes all elements from the queue
      void removeItems​(com.google.common.base.Predicate<T> predicate)
      Removes all matched elements
      void removeItems​(java.util.Date olderThan)
      Removes all elements from the queue older than a specific date
      void setMaxCapacity​(int maxCapacity)  
      • Methods inherited from class java.util.TreeMap

        ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, remove, replace, replace, replaceAll, size, subMap, subMap, tailMap, tailMap, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, isEmpty, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove
    • Field Detail

    • Constructor Detail

      • AbstractUpdateQueue

        public AbstractUpdateQueue()
    • Method Detail

      • getItems

        public java.util.List<T> getItems()
        Description copied from interface: UpdateQueue
        Returns all elements in the queue.
        Specified by:
        getItems in interface UpdateQueue<T>
        Returns:
        list of stored elements
      • getItems

        public java.util.List<T> getItems​(java.util.Date newerThan)
        Description copied from interface: UpdateQueue
        Returns all elements in the queue newer than a specific day
        Specified by:
        getItems in interface UpdateQueue<T>
        Parameters:
        newerThan - threshold date
        Returns:
        list of stored elements
      • addItem

        public void addItem​(T item)
        Description copied from interface: UpdateQueue
        Adds item to the queue
        Specified by:
        addItem in interface UpdateQueue<T>
        Parameters:
        item - elements to be stored
      • addItems

        public void addItems​(java.util.List<T> items)
        Description copied from interface: UpdateQueue
        Adds all elements from the list to the queue
        Specified by:
        addItems in interface UpdateQueue<T>
        Parameters:
        items - elements to be stored
      • removeItems

        public void removeItems​(java.util.Date olderThan)
        Description copied from interface: UpdateQueue
        Removes all elements from the queue older than a specific date
        Specified by:
        removeItems in interface UpdateQueue<T>
        Parameters:
        olderThan - threshold date
      • removeItems

        public void removeItems()
        Description copied from interface: UpdateQueue
        Removes all elements from the queue
        Specified by:
        removeItems in interface UpdateQueue<T>
      • removeItems

        public void removeItems​(com.google.common.base.Predicate<T> predicate)
        Description copied from interface: UpdateQueue
        Removes all matched elements
        Specified by:
        removeItems in interface UpdateQueue<T>
      • getLastItem

        public T getLastItem()
        Description copied from interface: UpdateQueue
        Returns last item from the queue
        Specified by:
        getLastItem in interface UpdateQueue<T>
        Returns:
        last element
      • getMaxCapacity

        public int getMaxCapacity()
      • setMaxCapacity

        public void setMaxCapacity​(int maxCapacity)
      • getTimeKey

        protected java.lang.Long getTimeKey​(T item)