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
modCount
Constructor and Description |
---|
ModifiableObservableListBase() |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
E element) |
boolean |
addAll(Collection<? extends E> c) |
boolean |
addAll(int index,
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(Object o) |
boolean |
removeAll(Collection<?> c) |
protected void |
removeRange(int fromIndex,
int toIndex) |
boolean |
retainAll(Collection<?> c) |
E |
set(int index,
E element) |
boolean |
setAll(Collection<? extends E> col)
Clears the ObservableList and add all elements from the collection.
|
abstract int |
size() |
List<E> |
subList(int fromIndex,
int toIndex) |
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, 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
add, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
public boolean setAll(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(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class AbstractCollection<E>
public boolean addAll(int index, Collection<? extends E> c)
protected void removeRange(int fromIndex, int toIndex)
removeRange
in class AbstractList<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
removeAll
in interface List<E>
removeAll
in class AbstractCollection<E>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
retainAll
in interface List<E>
retainAll
in class AbstractCollection<E>
public void add(int index, E element)
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface List<E>
remove
in class AbstractCollection<E>
public E remove(int index)
public abstract E get(int index)
public abstract int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class AbstractCollection<E>
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 addedClassCastException
NullPointerException
IllegalArgumentException
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 positionClassCastException
NullPointerException
IllegalArgumentException
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 elementIndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.