Class ListeningCollection<T>

  • Type Parameters:
    T - The entry type
    All Implemented Interfaces:
    java.lang.Iterable<T>, java.util.Collection<T>

    public class ListeningCollection<T>
    extends java.util.AbstractCollection<T>
    This is a proxy of a collection that notifies a listener on every collection change
    Since:
    12267 (extracted from GpxData), 12156
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<T> base  
      private java.lang.Runnable runOnModification  
    • Constructor Summary

      Constructors 
      Constructor Description
      ListeningCollection​(java.util.List<T> base, java.lang.Runnable runOnModification)
      Constructs a new ListeningCollection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T e)  
      protected void added​(T object)
      Called when an object is added.
      java.util.Iterator<T> iterator()  
      boolean remove​(java.lang.Object o)  
      protected void removed​(T object)
      Called when an object is removed.
      int size()  
      • Methods inherited from class java.util.AbstractCollection

        addAll, clear, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

      • base

        private final java.util.List<T> base
    • Constructor Detail

      • ListeningCollection

        public ListeningCollection​(java.util.List<T> base,
                                   java.lang.Runnable runOnModification)
        Constructs a new ListeningCollection.
        Parameters:
        base - base collection
        runOnModification - runnable run at each modification
        Since:
        12269
    • Method Detail

      • iterator

        public final java.util.Iterator<Titerator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in class java.util.AbstractCollection<T>
      • size

        public final int size()
        Specified by:
        size in interface java.util.Collection<T>
        Specified by:
        size in class java.util.AbstractCollection<T>
      • remove

        public final boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<T>
        Overrides:
        remove in class java.util.AbstractCollection<T>
      • add

        public final boolean add​(T e)
        Specified by:
        add in interface java.util.Collection<T>
        Overrides:
        add in class java.util.AbstractCollection<T>
      • removed

        protected void removed​(T object)
        Called when an object is removed.
        Parameters:
        object - the removed object
      • added

        protected void added​(T object)
        Called when an object is added.
        Parameters:
        object - the added object