E
- the type of the elements contained in the Listpublic abstract class ModifiableObservableListBase<E> extends ObservableListBase<E>
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); }
ObservableListBase
Modifier and Type | Class and Description |
---|---|
private class |
ModifiableObservableListBase.SubObservableList |
Constructor and Description |
---|
ModifiableObservableListBase() |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
E element) |
boolean |
addAll(java.util.Collection<? extends E> c) |
boolean |
addAll(int index,
java.util.Collection<? extends E> c) |
protected abstract void |
doAdd(int index,
E element)
Adds the
element to the List at the position of index . |
protected abstract E |
doRemove(int index)
Removes the element at position of
index . |
protected abstract E |
doSet(int index,
E element)
Sets the
element in the List at the position of index . |
abstract E |
get(int index) |
E |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
protected void |
removeRange(int fromIndex,
int toIndex) |
boolean |
retainAll(java.util.Collection<?> c) |
E |
set(int index,
E element) |
boolean |
setAll(java.util.Collection<? extends E> col)
Clears the ObservableList and adds all elements from the collection.
|
abstract int |
size() |
java.util.List<E> |
subList(int fromIndex,
int toIndex) |
addAll, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, retainAll, setAll
add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator
contains, containsAll, isEmpty, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
filtered, sorted, sorted
public boolean setAll(java.util.Collection<? extends E> col)
ObservableList
setAll
in interface ObservableList<E>
setAll
in class ObservableListBase<E>
col
- the collection with elements that will be added to this observableArrayListpublic boolean addAll(java.util.Collection<? extends E> c)
public boolean addAll(int index, java.util.Collection<? extends E> c)
protected void removeRange(int fromIndex, int toIndex)
removeRange
in class java.util.AbstractList<E>
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public void add(int index, E element)
public boolean remove(java.lang.Object o)
public E remove(int index)
public java.util.List<E> subList(int fromIndex, int toIndex)
public abstract E get(int index)
public abstract int size()
protected abstract void doAdd(int index, E element)
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.
index
- the position where to add the elementelement
- the element that will be addedjava.lang.ClassCastException
- if the type of the specified element is
incompatible with this listjava.lang.NullPointerException
- if the specified arguments contain one or
more null elementsjava.lang.IllegalArgumentException
- if some property of this element
prevents it from being added to this listjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size())
protected abstract E doSet(int index, E element)
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.
index
- the position where to set the elementelement
- the element that will be set at the specified positionjava.lang.ClassCastException
- if the type of the specified element is
incompatible with this listjava.lang.NullPointerException
- if the specified arguments contain one or
more null elementsjava.lang.IllegalArgumentException
- if some property of this element
prevents it from being added to this listjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())
protected abstract E doRemove(int index)
index
.index
- the index of the removed elementjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())