Class ObservableCollection<E,C extends Collection<E>>

java.lang.Object
net.sf.jstuff.core.collection.ObservableCollection<E,C>
All Implemented Interfaces:
Iterable<E>, Collection<E>, CollectionExt<E>, EventListenable<ObservableCollection.ChangeEvent<E>>
Direct Known Subclasses:
ObservableList, ObservableSet

public class ObservableCollection<E,C extends Collection<E>> extends Object implements CollectionExt<E>, EventListenable<ObservableCollection.ChangeEvent<E>>
A Collection wrapper that emits ObservableCollection.ChangeEvents when modified through this ObservableCollection.

Changes made directly to the underlying Collection instance are not observable and will not trigger events.

ObservableCollection.ChangeEvents may include index information if the underlying collection has a defined order:

  • For collections with insertion order (e.g. List, LinkedHashSet), added and removed items include their index.
  • For collections with stable iteration order (e.g. SortedSet), only removed items include their index.
  • For unordered collections (e.g. HashSet), indices are -1.

Listeners can subscribe to receive ObservableCollection.ChangeEvents describing the type of change and the affected items.

Author:
Sebastian Thomschke