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>
public abstract class ModifiableObservableListBase<E> extends ObservableListBase<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 java.util.AbstractList
modCount
Constructor Summary
| Constructor | Description |
|---|---|
ModifiableObservableListBase() |
Creates a default ModifiableObservableListBase. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
void |
add |
|
boolean |
addAll |
|
boolean |
addAll |
|
protected abstract void |
doAdd |
Adds the element to the List at the position of index. |
protected abstract E |
doRemove |
Removes the element at position of index. |
protected abstract E |
doSet |
Sets the element in the List at the position of index. |
abstract E |
get |
|
E |
remove |
|
boolean |
remove |
|
boolean |
removeAll |
|
boolean |
retainAll |
|
E |
set |
|
List |
subList |
Methods declared in class javafx.collections.ObservableListBase
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll, setAll
Methods declared in class java.util.AbstractList
add, add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
Methods declared in class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toString
Methods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods declared in interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods declared in interface java.util.List
add, addFirst, addLast, clear, contains, containsAll, equals, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeFirst, removeLast, replaceAll, reversed, size, sort, spliterator, toArray, toArray
Methods declared in interface javafx.beans.Observable
subscribe
Methods declared in interface javafx.collections.ObservableList
filtered, sorted, sorted
Constructor Details
ModifiableObservableListBase
public ModifiableObservableListBase()
Creates a default
ModifiableObservableListBase.Method Details
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
-
addAllin interfaceCollection<E> - Specified by:
-
addAllin interfaceList<E> - Overrides:
-
addAllin classAbstractCollection<E>
addAll
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
-
removeAllin interfaceCollection<E> - Specified by:
-
removeAllin interfaceList<E> - Overrides:
-
removeAllin classAbstractCollection<E>
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
-
retainAllin interfaceCollection<E> - Specified by:
-
retainAllin interfaceList<E> - Overrides:
-
retainAllin classAbstractCollection<E>
add
set
remove
public boolean remove(Object o)
- Specified by:
-
removein interfaceCollection<E> - Specified by:
-
removein interfaceList<E> - Overrides:
-
removein classAbstractCollection<E>
remove
subList
get
doAdd
protected abstract void doAdd(int index, E element)
Adds the
element to the List at the position of index. 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 element -
element- the element that will be added - Throws:
-
ClassCastException- if the type of the specified element is incompatible with this list -
NullPointerException- if the specified arguments contain one or more null elements -
IllegalArgumentException- if some property of this element prevents it from being added to this list -
IndexOutOfBoundsException- if the index is out of range(index < 0 || index > size())
doSet
protected abstract E doSet(int index, E element)
Sets the
element in the List at the position of index. For the description of possible exceptions, please refer to the documentation of set(int, java.lang.Object) method.
- Parameters:
-
index- the position where to set the element -
element- 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 list -
NullPointerException- if the specified arguments contain one or more null elements -
IllegalArgumentException- if some property of this element prevents it from being added to this list -
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
doRemove
protected abstract E doRemove(int index)
Removes the element at position of
index.- 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())
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.