Class ModifiableObservableListBase<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
javafx.collections.ObservableListBase<E>
javafx.collections.ModifiableObservableListBase<E>
- Type Parameters:
E- the type of the elements contained in the List
- All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>, Observable, ObservableList<E>
Abstract class that serves as a base class for
ObservableList implementations that are modifiable.
To implement a modifiable ObservableList class, you just need to implement the following set of methods:
and the notifications and built and fired automatically for you.
Example of a simple ObservableList delegating to another List would look like this:
public class ArrayObservableList<E> extends ModifiableObservableList<E> {
private final List<E> delegate = new ArrayList<>();
public E get(int index) {
return delegate.get(index);
}
public int size() {
return delegate.size();
}
protected void doAdd(int index, E element) {
delegate.add(index, element);
}
protected E doSet(int index, E element) {
return delegate.set(index, element);
}
protected E doRemove(int index) {
return delegate.remove(index);
}
- Since:
- JavaFX 8.0
- See Also:
-
Field Summary
Fields declared in class AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionCreates a defaultModifiableObservableListBase. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAll(Collection<? extends E> c) protected abstract voidAdds theelementto the List at the position ofindex.protected abstract EdoRemove(int index) Removes the element at position ofindex.protected abstract ESets theelementin the List at the position ofindex.booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) Methods declared in class ObservableListBase
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll, setAllModifier and TypeMethodDescriptionbooleanA convenience method for var-arg addition of elements.final voidaddListener(InvalidationListener listener) Adds anInvalidationListenerwhich will be notified whenever theObservablebecomes invalid.final voidaddListener(ListChangeListener<? super E> listener) Add a listener to this observable list.protected final voidBegins a change block.protected final voidEnds the change block.protected final voidfireChange(ListChangeListener.Change<? extends E> change) Notifies all listeners of a changeprotected final booleanReturns true if there are some listeners registered for this list.protected final voidnextAdd(int from, int to) Adds a new add operation to the change.protected final voidnextPermutation(int from, int to, int[] perm) Adds a new permutation operation to the change.protected final voidnextRemove(int idx, E removed) Adds a new remove operation to the change with single item removed.protected final voidnextRemove(int idx, List<? extends E> removed) Adds a new remove operation to the change with multiple items removed.protected final voidnextReplace(int from, int to, List<? extends E> removed) Adds a new replace operation to the change.protected final voidAdds a new set operation to the change.protected final voidnextUpdate(int pos) Adds a new update operation to the change.voidremove(int from, int to) A simplified way of callingsublist(from, to).clear().booleanA convenience method for var-arg usage of theremoveAllmethod.final voidremoveListener(InvalidationListener listener) Removes the given listener from the list of listeners, that are notified whenever the value of theObservablebecomes invalid.final voidremoveListener(ListChangeListener<? super E> listener) Tries to remove a listener from this observable list.booleanA convenience method for var-arg usage of theretainAllmethod.booleanClears the ObservableList and adds all the elements passed as var-args.booleansetAll(Collection<? extends E> col) Clears the ObservableList and adds all elements from the collection.Methods declared in class AbstractList
add, add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods declared in class AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toStringMethods declared in interface Collection
parallelStream, removeIf, stream, toArrayMethods declared in interface List
addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, removeFirst, removeLast, replaceAll, reversed, size, sort, spliterator, toArray, toArrayMethods declared in interface Observable
subscribeModifier and TypeMethodDescriptiondefault SubscriptionCreates aSubscriptionon thisObservablewhich callsinvalidationSubscriberwhenever it becomes invalid.Methods declared in interface ObservableList
filtered, replaceRange, sorted, sortedModifier and TypeMethodDescriptiondefault FilteredList<E> Creates aFilteredListwrapper of this list using the specified predicate.default booleanreplaceRange(int from, int to, Collection<? extends E> col) Replaces the elements in the range[from, to)with the elements from the given collection.default SortedList<E> sorted()Creates aSortedListwrapper of this list with the natural ordering.default SortedList<E> sorted(Comparator<E> comparator) Creates aSortedListwrapper of this list using the specified comparator.
-
Constructor Details
-
ModifiableObservableListBase
public ModifiableObservableListBase()Creates a defaultModifiableObservableListBase.
-
-
Method Details
-
addAll
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classAbstractCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classAbstractCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceList<E>- Overrides:
retainAllin classAbstractCollection<E>
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractCollection<E>
-
doAdd
Adds theelementto the List at the position ofindex.For the description of possible exceptions, please refer to the documentation of
AbstractList.add(java.lang.Object)method.- Parameters:
index- the position where to add the elementelement- the element that will be added- Throws:
ClassCastException- if the type of the specified element is incompatible with this listNullPointerException- if the specified arguments contain one or more null elementsIllegalArgumentException- if some property of this element prevents it from being added to this listIndexOutOfBoundsException- if the index is out of range(index < 0 || index > size())
-
doSet
Sets theelementin the List at the position ofindex.For the description of possible exceptions, please refer to the documentation of
AbstractList.set(int, java.lang.Object)method.- Parameters:
index- the position where to set the elementelement- the element that will be set at the specified position- Returns:
- the old element at the specified position
- Throws:
ClassCastException- if the type of the specified element is incompatible with this listNullPointerException- if the specified arguments contain one or more null elementsIllegalArgumentException- if some property of this element prevents it from being added to this listIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
doRemove
Removes the element at position ofindex.- Parameters:
index- the index of the removed element- Returns:
- the removed element
- Throws:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-