Class TransformedList<S,​E>

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, E value)
      Inserts the specified element at the specified position in this list (optional operation).
      boolean addAll​(int index, java.util.Collection<? extends E> values)
      Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
      void clear()
      Removes all of the elements from this list (optional operation).
      void dispose()
      Releases the resources consumed by this TransformedList so that it may eventually be garbage collected.
      E get​(int index)
      Returns the element at the specified position in this list.
      protected int getSourceIndex​(int mutationIndex)
      Gets the index in the source EventList that corresponds to the specified index.
      protected abstract boolean isWritable()
      Gets whether the source EventList is writable via this API.
      abstract void listChanged​(ListEvent<S> listChanges)
      When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.
      E remove​(int index)
      Removes the element at the specified position in this list (optional operation).
      boolean removeAll​(java.util.Collection<?> collection)
      Removes from this list all the elements that are contained in the specified collection (optional operation).
      boolean retainAll​(java.util.Collection<?> values)
      Retains only the elements in this list that are contained in the specified collection (optional operation).
      E set​(int index, E value)
      Replaces the element at the specified position in this list with the specified element (optional operation).
      int size()
      Returns the number of elements in this list.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        replaceAll, sort, spliterator
    • Field Detail

      • source

        protected EventList<S> source
        the event list to transform
    • Method Detail

      • getSourceIndex

        protected int getSourceIndex​(int mutationIndex)
        Gets the index in the source EventList that corresponds to the specified index. More formally, returns the index such that
        this.get(i) == source.get(getSourceIndex(i)) for all legal values of i.
      • isWritable

        protected abstract boolean isWritable()
        Gets whether the source EventList is writable via this API.

        Extending classes must override this method in order to make themselves writable.

      • listChanged

        public abstract void listChanged​(ListEvent<S> listChanges)
        When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.

        It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.

        Specified by:
        listChanged in interface ListEventListener<S>
        Parameters:
        listChanges - a ListEvent describing the changes to the list
      • add

        public void add​(int index,
                        E value)
        Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
        Specified by:
        add in interface java.util.List<S>
        Overrides:
        add in class AbstractEventList<E>
        Parameters:
        index - index at which the specified element is to be inserted.
        value - element to be inserted.
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> values)
        Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
        Specified by:
        addAll in interface java.util.List<S>
        Overrides:
        addAll in class AbstractEventList<E>
        Parameters:
        index - index at which to insert first element from the specified collection.
        values - elements to be inserted into this list.
        Returns:
        true if this list changed as a result of the call.
      • clear

        public void clear()
        Removes all of the elements from this list (optional operation). This list will be empty after this call returns (unless it throws an exception).
        Specified by:
        clear in interface java.util.Collection<S>
        Specified by:
        clear in interface java.util.List<S>
        Overrides:
        clear in class AbstractEventList<E>
      • get

        public E get​(int index)
        Returns the element at the specified position in this list.
        Specified by:
        get in interface java.util.List<S>
        Specified by:
        get in class AbstractEventList<E>
        Parameters:
        index - index of element to return.
        Returns:
        the element at the specified position in this list.
      • remove

        public E remove​(int index)
        Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
        Specified by:
        remove in interface java.util.List<S>
        Overrides:
        remove in class AbstractEventList<E>
        Parameters:
        index - the index of the element to removed.
        Returns:
        the element previously at the specified position.
      • removeAll

        public boolean removeAll​(java.util.Collection<?> collection)
        Removes from this list all the elements that are contained in the specified collection (optional operation).
        Specified by:
        removeAll in interface java.util.Collection<S>
        Specified by:
        removeAll in interface java.util.List<S>
        Overrides:
        removeAll in class AbstractEventList<E>
        Parameters:
        collection - collection that defines which elements will be removed from this list.
        Returns:
        true if this list changed as a result of the call.
        See Also:
        AbstractEventList.remove(Object), AbstractEventList.contains(Object)
      • retainAll

        public boolean retainAll​(java.util.Collection<?> values)
        Retains only the elements in this list that are contained in the specified collection (optional operation). In other words, removes from this list all the elements that are not contained in the specified collection.
        Specified by:
        retainAll in interface java.util.Collection<S>
        Specified by:
        retainAll in interface java.util.List<S>
        Overrides:
        retainAll in class AbstractEventList<E>
        Parameters:
        values - collection that defines which elements this set will retain.
        Returns:
        true if this list changed as a result of the call.
        See Also:
        AbstractEventList.remove(Object), AbstractEventList.contains(Object)
      • set

        public E set​(int index,
                     E value)
        Replaces the element at the specified position in this list with the specified element (optional operation).
        Specified by:
        set in interface java.util.List<S>
        Overrides:
        set in class AbstractEventList<E>
        Parameters:
        index - index of element to replace.
        value - element to be stored at the specified position.
        Returns:
        the element previously at the specified position.
      • size

        public int size()
        Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Specified by:
        size in interface java.util.Collection<S>
        Specified by:
        size in interface java.util.List<S>
        Specified by:
        size in class AbstractEventList<E>
        Returns:
        the number of elements in this list.