Package org.openstreetmap.josm.tools
Class ListeningCollection<T>
- java.lang.Object
-
- java.util.AbstractCollection<T>
-
- org.openstreetmap.josm.tools.ListeningCollection<T>
-
- Type Parameters:
T
- The entry type
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
public class ListeningCollection<T> extends 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 List<T>
base
private Runnable
runOnModification
-
Constructor Summary
Constructors Constructor Description ListeningCollection(List<T> base, Runnable runOnModification)
Constructs a newListeningCollection
.
-
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.Iterator<T>
iterator()
boolean
remove(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
-
-
-
-
Field Detail
-
runOnModification
private final Runnable runOnModification
-
-
Constructor Detail
-
ListeningCollection
public ListeningCollection(List<T> base, Runnable runOnModification)
Constructs a newListeningCollection
.- Parameters:
base
- base collectionrunOnModification
- runnable run at each modification- Since:
- 12269
-
-
Method Detail
-
iterator
public final Iterator<T> iterator()
- Specified by:
iterator
in interfaceCollection<T>
- Specified by:
iterator
in interfaceIterable<T>
- Specified by:
iterator
in classAbstractCollection<T>
-
size
public final int size()
- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in classAbstractCollection<T>
-
remove
public final boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<T>
- Overrides:
remove
in classAbstractCollection<T>
-
add
public final boolean add(T e)
- Specified by:
add
in interfaceCollection<T>
- Overrides:
add
in classAbstractCollection<T>
-
removed
protected void removed(T object)
Called when an object is removed.- Parameters:
object
- the removed object
-
-