javafx.collections

## 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>, 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:
  - `get(int)`
  - `size()`
  - `doAdd(int, Object)`
  - `doRemove(int)`
  - `doSet(int, Object)`
  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:
    `ObservableListBase`

- - ### Field Summary

    - ### Fields inherited from class java.util.AbstractList

      `modCount`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModifiableObservableListBase()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    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)`

    - ### Methods inherited from class javafx.collections.ObservableListBase

      `addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll`

    - ### Methods inherited from class java.util.AbstractList

      `add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator`

    - ### Methods inherited from class java.util.AbstractCollection

      `contains, containsAll, isEmpty, toArray, toArray, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface javafx.collections.ObservableList

      `filtered, sorted, sorted`

    - ### Methods inherited from interface java.util.List

      `add, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, sort, spliterator, toArray, toArray`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Constructor Detail

    - #### ModifiableObservableListBase

          public ModifiableObservableListBase()

  - ### Method Detail

    - #### setAll

          public boolean setAll(Collection<? extends E> col)

      Description copied from interface: `ObservableList`
      Clears the ObservableList and add all elements from the collection.
      Specified by:
        `setAll` in interface `ObservableList<E>`
      Overrides:
        `setAll` in class `ObservableListBase<E>`
      Parameters:
        `col` - the collection with elements that will be added to this observableArrayList
      Returns:
        true (as specified by Collection.add(E))

    - #### addAll

          public boolean addAll(Collection<? extends E> c)

      Specified by:
        `addAll` in interface `Collection<E>`
      Specified by:
        `addAll` in interface `List<E>`
      Overrides:
        `addAll` in class `AbstractCollection<E>`

    - #### addAll

          public boolean addAll(int index,
                                Collection<? extends E> c)

      Specified by:
        `addAll` in interface `List<E>`
      Overrides:
        `addAll` in class `AbstractList<E>`

    - #### removeRange

          protected void removeRange(int fromIndex,
                                     int toIndex)

      Overrides:
        `removeRange` in class `AbstractList<E>`

    - #### removeAll

          public boolean removeAll(Collection<?> c)

      Specified by:
        `removeAll` in interface `Collection<E>`
      Specified by:
        `removeAll` in interface `List<E>`
      Overrides:
        `removeAll` in class `AbstractCollection<E>`

    - #### retainAll

          public boolean retainAll(Collection<?> c)

      Specified by:
        `retainAll` in interface `Collection<E>`
      Specified by:
        `retainAll` in interface `List<E>`
      Overrides:
        `retainAll` in class `AbstractCollection<E>`

    - #### add

          public void add(int index,
                          E element)

      Specified by:
        `add` in interface `List<E>`
      Overrides:
        `add` in class `AbstractList<E>`

    - #### set

          public E set(int index,
                       E element)

      Specified by:
        `set` in interface `List<E>`
      Overrides:
        `set` in class `AbstractList<E>`

    - #### remove

          public boolean remove(Object o)

      Specified by:
        `remove` in interface `Collection<E>`
      Specified by:
        `remove` in interface `List<E>`
      Overrides:
        `remove` in class `AbstractCollection<E>`

    - #### remove

          public E remove(int index)

      Specified by:
        `remove` in interface `List<E>`
      Overrides:
        `remove` in class `AbstractList<E>`

    - #### subList

          public List<E> subList(int fromIndex,
                                 int toIndex)

      Specified by:
        `subList` in interface `List<E>`
      Overrides:
        `subList` in class `AbstractList<E>`

    - #### get

          public abstract E get(int index)

      Specified by:
        `get` in interface `List<E>`
      Specified by:
        `get` in class `AbstractList<E>`

    - #### size

          public abstract int size()

      Specified by:
        `size` in interface `Collection<E>`
      Specified by:
        `size` in interface `List<E>`
      Specified by:
        `size` in class `AbstractCollection<E>`

    - #### 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`
        `NullPointerException`
        `IllegalArgumentException`
        `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`
        `NullPointerException`
        `IllegalArgumentException`
        `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()`)

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2019, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.