View Javadoc

1   package cz.cuni.amis.utils.collections;
2   
3   import java.util.Collection;
4   import java.util.EventListener;
5   
6   /**
7    * Listener on collection change events.
8    * @author Ik
9    * @param <E>
10   */
11  public interface CollectionEventListener<E> extends EventListener {
12  
13      /**
14       * Called before the elements will be added to the collection.
15       * @param toBeAdded collection of items to be added, in case of one item this contains a collection with one item
16       * @param whereToAdd
17       */
18      void preAddEvent(Collection<E> toBeAdded, Collection<E> whereToAdd);
19  
20      /**
21       * Called after the elements were added to the collection.
22       * @param alreadyAdded
23       * @param whereWereAdded
24       */
25      void postAddEvent(Collection<E> alreadyAdded, Collection<E> whereWereAdded);
26  
27      /**
28       * Called before the elements will be removed from the collection.
29       * @param toBeRemoved
30       * @param whereToRemove
31       */
32      void preRemoveEvent(Collection<E> toBeRemoved, Collection<E> whereToRemove);
33  
34      /**
35       * Called after the elements were removed from the collection.
36       * @param alreadyAdded
37       * @param whereWereRemoved
38       */
39      void postRemoveEvent(Collection<E> alreadyAdded, Collection<E> whereWereRemoved);
40  }