Class VetoableListDecorator<E>

java.lang.Object
com.sun.javafx.collections.VetoableListDecorator<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, Observable, ObservableList<E>

public abstract class VetoableListDecorator<E> extends Object implements ObservableList<E>
  • Constructor Details

    • VetoableListDecorator

      public VetoableListDecorator(ObservableList<E> decorated)
  • Method Details

    • onProposedChange

      protected abstract void onProposedChange(List<E> toBeAdded, int... indexes)
      The type of the change can be observed from the combination of arguments.
      • If something is going to be added toBeAdded is non-empty and indexes contain two indexes that are pointing to the position, e.g. {2, 2}
      • If something is going to be removed, the indexes are paired by two: from(inclusive)-to(exclusive) and are pointing to the current list.
        E.g. if we remove 2,3,5 from list {0,1,2,3,4,5}, the indexes will be {2, 4, 5, 6}. If there's more than one pair of indexes, toBeAdded is always empty.
      • for set toBeAdded contains 1 element and indexes are like with removal: {index, index + 1}
      • for setAll, toBeAdded contains all new elements and indexes looks like this: {0, size()}
      Note that it's always safe to iterate over toBeAdded and use indexes as pairs of from-to, as there's always at least one pair.
      Parameters:
      toBeAdded - the list to be added
      Throws:
      IllegalArgumentException - when the change is vetoed
    • addListener

      public void addListener(ListChangeListener<? super E> listener)
      Description copied from interface: ObservableList
      Add a listener to this observable list.
      Specified by:
      addListener in interface ObservableList<E>
      Parameters:
      listener - the listener for listening to the list changes
    • removeListener

      public void removeListener(ListChangeListener<? super E> listener)
      Description copied from interface: ObservableList
      Tries to removed a listener from this observable list. If the listener is not attached to this list, nothing happens.
      Specified by:
      removeListener in interface ObservableList<E>
      Parameters:
      listener - a listener to remove
    • addListener

      public void addListener(InvalidationListener listener)
      Description copied from interface: Observable
      Adds an InvalidationListener which will be notified whenever the Observable becomes invalid. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.

      Note that the same actual InvalidationListener instance may be safely registered for different Observables.

      The Observable stores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by calling removeListener after use or to use an instance of WeakInvalidationListener avoid this situation.

      Specified by:
      addListener in interface Observable
      Parameters:
      listener - The listener to register
      See Also:
    • removeListener

      public void removeListener(InvalidationListener listener)
      Description copied from interface: Observable
      Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

      If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.

      Specified by:
      removeListener in interface Observable
      Parameters:
      listener - The listener to remove
      See Also:
    • addAll

      public boolean addAll(E... elements)
      Description copied from interface: ObservableList
      A convenient method for var-arg adding of elements.
      Specified by:
      addAll in interface ObservableList<E>
      Parameters:
      elements - the elements to add
      Returns:
      true (as specified by Collection.add(E))
    • setAll

      public boolean setAll(E... elements)
      Description copied from interface: ObservableList
      Clears the ObservableList and add all the elements passed as var-args.
      Specified by:
      setAll in interface ObservableList<E>
      Parameters:
      elements - the elements to set
      Returns:
      true (as specified by Collection.add(E))
    • 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>
      Parameters:
      col - the collection with elements that will be added to this observableArrayList
      Returns:
      true (as specified by Collection.add(E))
    • removeAll

      public boolean removeAll(E... elements)
      Description copied from interface: ObservableList
      A convenient method for var-arg usage of removaAll method.
      Specified by:
      removeAll in interface ObservableList<E>
      Parameters:
      elements - the elements to be removed
      Returns:
      true if list changed as a result of this call
    • retainAll

      public boolean retainAll(E... elements)
      Description copied from interface: ObservableList
      A convenient method for var-arg usage of retain method.
      Specified by:
      retainAll in interface ObservableList<E>
      Parameters:
      elements - the elements to be retained
      Returns:
      true if list changed as a result of this call
    • remove

      public void remove(int from, int to)
      Description copied from interface: ObservableList
      Basically a shortcut to sublist(from, to).clear() As this is a common operation, ObservableList has this method for convenient usage.
      Specified by:
      remove in interface ObservableList<E>
      Parameters:
      from - the start of the range to remove (inclusive)
      to - the end of the range to remove (exclusive)
    • size

      public int size()
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface List<E>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<E>
      Specified by:
      isEmpty in interface List<E>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<E>
      Specified by:
      contains in interface List<E>
    • iterator

      public Iterator<E> iterator()
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface List<E>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<E>
      Specified by:
      toArray in interface List<E>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<E>
      Specified by:
      toArray in interface List<E>
    • add

      public boolean add(E e)
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface List<E>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<E>
      Specified by:
      remove in interface List<E>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<E>
      Specified by:
      containsAll in interface List<E>
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Specified by:
      addAll in interface Collection<E>
      Specified by:
      addAll in interface List<E>
    • addAll

      public boolean addAll(int index, Collection<? extends E> c)
      Specified by:
      addAll in interface List<E>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<E>
      Specified by:
      removeAll in interface List<E>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<E>
      Specified by:
      retainAll in interface List<E>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<E>
      Specified by:
      clear in interface List<E>
    • get

      public E get(int index)
      Specified by:
      get in interface List<E>
    • set

      public E set(int index, E element)
      Specified by:
      set in interface List<E>
    • add

      public void add(int index, E element)
      Specified by:
      add in interface List<E>
    • remove

      public E remove(int index)
      Specified by:
      remove in interface List<E>
    • indexOf

      public int indexOf(Object o)
      Specified by:
      indexOf in interface List<E>
    • lastIndexOf

      public int lastIndexOf(Object o)
      Specified by:
      lastIndexOf in interface List<E>
    • listIterator

      public ListIterator<E> listIterator()
      Specified by:
      listIterator in interface List<E>
    • listIterator

      public ListIterator<E> listIterator(int index)
      Specified by:
      listIterator in interface List<E>
    • subList

      public List<E> subList(int fromIndex, int toIndex)
      Specified by:
      subList in interface List<E>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<E>
      Specified by:
      equals in interface List<E>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<E>
      Specified by:
      hashCode in interface List<E>
      Overrides:
      hashCode in class Object