Class AbstractObservableList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.eclipse.core.databinding.observable.list.AbstractObservableList<E>
- Type Parameters:
E- the list element type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>,IObservable,IObservableCollection<E>,IObservableList<E>
- Direct Known Subclasses:
ComputedList,MultiList
public abstract class AbstractObservableList<E>
extends AbstractList<E>
implements IObservableList<E>
Subclasses should override at least get(int index) and size().
This class is thread safe. All state accessing methods must be invoked from
the current realm. Methods for adding and removing
listeners may be invoked from any thread.
- Since:
- 1.0
- Implementation Note:
- If methods are added to the interface which this class implements then implementations of those methods must be added to this class.
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidaddChangeListener(IChangeListener listener) Adds the given change listener to the list of change listeners.voidaddDisposeListener(IDisposeListener listener) Adds the given dispose listener to the list of dispose listeners.voidaddListChangeListener(IListChangeListener<? super E> listener) Adds the given list change listener to the list of list change listeners.voidaddStaleListener(IStaleListener listener) Adds the given stale listener to the list of stale listeners.protected voidAsserts that the realm is the current realm.booleanbooleancontainsAll(Collection<?> c) voiddispose()Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.protected abstract intbooleanprotected voidFires change event.protected voidfireListChange(ListDiff<E> diff) protected voidFires stale event.protected voidgetRealm()Returns the realm for this observable.inthashCode()protected booleanReturns whether this observable list has any registered listeners.intbooleanReturns whether the observable has been disposedbooleanisEmpty()booleanisStale()Returns whether the state of this observable is stale and is expected to change soon.iterator()intprotected voidmove(int oldIndex, int newIndex) Moves the element located atoldIndextonewIndex.booleanbooleanremoveAll(Collection<?> c) voidremoveChangeListener(IChangeListener listener) Removes the given change listener from the list of change listeners.voidremoveDisposeListener(IDisposeListener listener) Removes the given dispose listener from the list of dispose listeners.voidremoveListChangeListener(IListChangeListener<? super E> listener) Removes the given list change listener from the list of list change listeners.voidremoveStaleListener(IStaleListener listener) Removes the given stale listener from the list of stale listeners.booleanretainAll(Collection<?> c) final intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.util.AbstractList
add, clear, get, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.eclipse.core.databinding.observable.list.IObservableList
get, getElementType, listIterator, listIterator, remove, set, subListMethods inherited from interface java.util.List
add, addFirst, addLast, clear, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Constructor Details
-
AbstractObservableList
- Parameters:
realm- the realm; notnull
-
AbstractObservableList
public AbstractObservableList()
-
-
Method Details
-
hasListeners
protected boolean hasListeners()Returns whether this observable list has any registered listeners.- Returns:
- whether this observable list has any registered listeners.
- Since:
- 1.2
-
isStale
public boolean isStale()Description copied from interface:IObservableReturns whether the state of this observable is stale and is expected to change soon. A non-stale observable that becomes stale will notify its stale listeners. A stale object that becomes non-stale does so by changing its state and notifying its change listeners, it does not notify its stale listeners about becoming non-stale. Clients that do not expect asynchronous changes may ignore staleness of observable objects.- Specified by:
isStalein interfaceIObservable- Returns:
- true if this observable's state is stale and will change soon.
-
addListChangeListener
Description copied from interface:IObservableListAdds the given list change listener to the list of list change listeners.- Specified by:
addListChangeListenerin interfaceIObservableList<E>- Parameters:
listener- the change listener to add; notnull
-
removeListChangeListener
Description copied from interface:IObservableListRemoves the given list change listener from the list of list change listeners. Has no effect if the given listener is not registered as a list change listener.- Specified by:
removeListChangeListenerin interfaceIObservableList<E>- Parameters:
listener- the change listener to remove; notnull
-
fireListChange
-
addChangeListener
Description copied from interface:IObservableAdds the given change listener to the list of change listeners. Change listeners are notified about changes of the state of this observable in a generic way, without specifying the change that happened. To get the changed state, a change listener needs to query for the current state of this observable.- Specified by:
addChangeListenerin interfaceIObservable- Parameters:
listener- the listener to add; notnull
-
removeChangeListener
Description copied from interface:IObservableRemoves the given change listener from the list of change listeners. Has no effect if the given listener is not registered as a change listener.- Specified by:
removeChangeListenerin interfaceIObservable- Parameters:
listener- the listener to remove; notnull
-
addStaleListener
Description copied from interface:IObservableAdds the given stale listener to the list of stale listeners. Stale listeners are notified when an observable object becomes stale, not when is becomes non-stale.- Specified by:
addStaleListenerin interfaceIObservable- Parameters:
listener- the listener to add; notnull- See Also:
-
removeStaleListener
Description copied from interface:IObservableRemoves the given stale listener from the list of stale listeners. Has no effect if the given listener is not registered as a stale listener.- Specified by:
removeStaleListenerin interfaceIObservable- Parameters:
listener- the listener to remove; notnull
-
addDisposeListener
Description copied from interface:IObservableAdds the given dispose listener to the list of dispose listeners. Dispose listeners are notified when an observable has been disposed.- Specified by:
addDisposeListenerin interfaceIObservable- Parameters:
listener- the listener to add- Since:
- 1.2
-
removeDisposeListener
Description copied from interface:IObservableRemoves the given dispose listener from the list of dispose listeners. Has no effect if the given listener is not registered as a dispose listener.- Specified by:
removeDisposeListenerin interfaceIObservable- Parameters:
listener- the listener to remove- Since:
- 1.2
-
fireChange
protected void fireChange()Fires change event. Must be invoked from the current realm. -
fireStale
protected void fireStale()Fires stale event. Must be invoked from the current realm. -
firstListenerAdded
protected void firstListenerAdded() -
lastListenerRemoved
protected void lastListenerRemoved() -
isDisposed
public boolean isDisposed()Description copied from interface:IObservableReturns whether the observable has been disposed- Specified by:
isDisposedin interfaceIObservable- Returns:
- whether the observable has been disposed
- Since:
- 1.2
-
dispose
public void dispose()Description copied from interface:IObservableDisposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.- Specified by:
disposein interfaceIObservable
-
size
public final int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceIObservableList<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>
-
doGetSize
protected abstract int doGetSize()- Returns:
- the size
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceIObservableList<E>- Specified by:
isEmptyin interfaceList<E>- Overrides:
isEmptyin classAbstractCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceIObservableList<E>- Specified by:
containsin interfaceList<E>- Overrides:
containsin classAbstractCollection<E>
-
iterator
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIObservableList<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin interfaceList<E>- Overrides:
iteratorin classAbstractList<E>
-
toArray
- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceIObservableList<E>- Specified by:
toArrayin interfaceList<E>- Overrides:
toArrayin classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceIObservableList<E>- Specified by:
toArrayin interfaceList<E>- Overrides:
toArrayin classAbstractCollection<E>
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceIObservableList<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractList<E>
-
move
Moves the element located atoldIndextonewIndex. This method is equivalent to callingadd(newIndex, remove(oldIndex)).Subclasses should override this method to deliver list change notification for the remove and add operations in the same ListChangeEvent, as this allows
ListDiff.accept(ListDiffVisitor)to recognize the operation as a move.- Specified by:
movein interfaceIObservableList<E>- Parameters:
oldIndex- the element's position before the move. Must be within the range0 <= oldIndex < size().newIndex- the element's position after the move. Must be within the range0 <= newIndex < size().- Returns:
- the element that was moved.
- Throws:
IndexOutOfBoundsException- if either argument is out of range (0 <= index < size()).- Since:
- 1.1
- See Also:
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceIObservableList<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceIObservableList<E>- Specified by:
containsAllin interfaceList<E>- Overrides:
containsAllin classAbstractCollection<E>
-
addAll
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceIObservableList<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classAbstractCollection<E>
-
addAll
- Specified by:
addAllin interfaceIObservableList<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classAbstractList<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceIObservableList<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classAbstractCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceIObservableList<E>- Specified by:
retainAllin interfaceList<E>- Overrides:
retainAllin classAbstractCollection<E>
-
equals
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceIObservableList<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classAbstractList<E>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceIObservableList<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classAbstractList<E>
-
indexOf
- Specified by:
indexOfin interfaceIObservableList<E>- Specified by:
indexOfin interfaceList<E>- Overrides:
indexOfin classAbstractList<E>
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceIObservableList<E>- Specified by:
lastIndexOfin interfaceList<E>- Overrides:
lastIndexOfin classAbstractList<E>
-
getRealm
Description copied from interface:IObservableReturns the realm for this observable. Unless otherwise specified, getters and setters must be accessed from within this realm. Listeners will be within this realm when they receive events from this observable.Because observables can only be accessed from within one realm, and they always fire events on that realm, their state can be observed in an incremental way. It is always safe to call getters of an observable from within a change listener attached to that observable.
- Specified by:
getRealmin interfaceIObservable- Returns:
- the realm
-
checkRealm
protected void checkRealm()Asserts that the realm is the current realm.- Throws:
AssertionFailedException- if the realm is not the current realm- See Also:
-