Class MultiList<E>

  • Type Parameters:
    E - the type of the elements in the list
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, IObservable, IObservableCollection<E>, IObservableList<E>

    public class MultiList<E>
    extends AbstractObservableList<E>
    An observable list backed by an array of observable lists. This class supports all removal methods (including clear()), as well as the set(int, Object) method. All other mutator methods (addition methods and move(int, int)) throw an UnsupportedOperationException.
    Since:
    1.2
    • Constructor Detail

      • MultiList

        @Deprecated
        public MultiList​(IObservableList<E>[] lists)
        Deprecated.
        use MultiList(List) instead
        Constructs a MultiList in the default realm, and backed by the given observable lists.
        Parameters:
        lists - the array of observable lists backing this MultiList.
      • MultiList

        public MultiList​(java.util.List<IObservableList<E>> lists)
        Constructs a MultiList in the default realm, and backed by the given observable lists.
        Parameters:
        lists - the array of observable lists backing this MultiList.
        Since:
        1.6
      • MultiList

        @Deprecated
        public MultiList​(IObservableList<E>[] lists,
                         java.lang.Object elementType)
        Deprecated.
        Constructs a MultiList in the default realm backed by the given observable lists.
        Parameters:
        lists - the array of observable lists backing this MultiList.
        elementType - element type of the constructed list.
      • MultiList

        public MultiList​(java.util.List<IObservableList<E>> lists,
                         java.lang.Object elementType)
        Constructs a MultiList in the default realm backed by the given observable lists.
        Parameters:
        lists - the array of observable lists backing this MultiList.
        elementType - element type of the constructed list.
        Since:
        1.6
      • MultiList

        public MultiList​(Realm realm,
                         IObservableList<E>[] lists)
        Constructs a MultiList belonging to the given realm, and backed by the given observable lists.
        Parameters:
        realm - the observable's realm
        lists - the array of observable lists backing this MultiList
      • MultiList

        @Deprecated
        public MultiList​(Realm realm,
                         IObservableList<E>[] lists,
                         java.lang.Object elementType)
        Deprecated.
        Constructs a MultiList belonging to the given realm, and backed by the given observable lists.
        Parameters:
        realm - the observable's realm
        lists - the array of observable lists backing this MultiList
        elementType - element type of the constructed list.
      • MultiList

        public MultiList​(Realm realm,
                         java.util.List<IObservableList<E>> lists,
                         java.lang.Object elementType)
        Constructs a MultiList belonging to the given realm, and backed by the given observable lists.
        Parameters:
        realm - the observable's realm
        lists - the array of observable lists backing this MultiList
        elementType - element type of the constructed list.
        Since:
        1.6
    • Method Detail

      • getElementType

        public java.lang.Object getElementType()
        Description copied from interface: IObservableCollection
        Returns the element type of this observable collection, or null if this observable collection is untyped.
        Returns:
        the type of the elements or null if untyped
      • add

        public boolean add​(java.lang.Object o)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface IObservableList<E>
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class AbstractObservableList<E>
      • add

        public void add​(int index,
                        java.lang.Object o)
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.AbstractList<E>
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface IObservableList<E>
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class AbstractObservableList<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.List<E>
        Overrides:
        clear in class java.util.AbstractList<E>
      • get

        public E get​(int index)
        Specified by:
        get in interface IObservableList<E>
        Specified by:
        get in interface java.util.List<E>
        Specified by:
        get in class java.util.AbstractList<E>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface IObservableList<E>
        Specified by:
        contains in interface java.util.List<E>
        Overrides:
        contains in class AbstractObservableList<E>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface IObservableList<E>
        Specified by:
        equals in interface java.util.List<E>
        Overrides:
        equals in class AbstractObservableList<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface IObservableList<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.List<E>
        Overrides:
        iterator in class AbstractObservableList<E>
      • listIterator

        public java.util.ListIterator<E> listIterator​(int index)
        Specified by:
        listIterator in interface IObservableList<E>
        Specified by:
        listIterator in interface java.util.List<E>
        Overrides:
        listIterator in class java.util.AbstractList<E>
      • move

        public E move​(int oldIndex,
                      int newIndex)
        Description copied from class: AbstractObservableList
        Moves the element located at oldIndex to newIndex. This method is equivalent to calling add(newIndex, remove(oldIndex)).

        Subclasses should override this method to deliver list change notification for the remove and add operations in the same ListChangeEvent, as this allows ListDiff.accept(ListDiffVisitor) to recognize the operation as a move.

        Specified by:
        move in interface IObservableList<E>
        Overrides:
        move in class AbstractObservableList<E>
        Parameters:
        oldIndex - the element's position before the move. Must be within the range 0 <= oldIndex < size().
        newIndex - the element's position after the move. Must be within the range 0 <= newIndex < size().
        Returns:
        the element that was moved.
        See Also:
        ListDiffVisitor.handleMove(int, int, Object), ListDiff.accept(ListDiffVisitor)
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface IObservableList<E>
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class AbstractObservableList<E>
      • remove

        public E remove​(int index)
        Specified by:
        remove in interface IObservableList<E>
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.AbstractList<E>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface IObservableList<E>
        Specified by:
        removeAll in interface java.util.List<E>
        Overrides:
        removeAll in class AbstractObservableList<E>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface IObservableList<E>
        Specified by:
        retainAll in interface java.util.List<E>
        Overrides:
        retainAll in class AbstractObservableList<E>
      • set

        public E set​(int index,
                     E o)
        Specified by:
        set in interface IObservableList<E>
        Specified by:
        set in interface java.util.List<E>
        Overrides:
        set in class java.util.AbstractList<E>
      • isStale

        public boolean isStale()
        Description copied from interface: IObservable
        Returns whether the state of this observable is stale and is expected to change soon. A non-stale observable that becomes stale will notify its stale listeners. A stale object that becomes non-stale does so by changing its state and notifying its change listeners, it does not notify its stale listeners about becoming non-stale. Clients that do not expect asynchronous changes may ignore staleness of observable objects.
        Specified by:
        isStale in interface IObservable
        Overrides:
        isStale in class AbstractObservableList<E>
        Returns:
        true if this observable's state is stale and will change soon.
      • dispose

        public void dispose()
        Description copied from interface: IObservable
        Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.
        Specified by:
        dispose in interface IObservable
        Overrides:
        dispose in class AbstractObservableList<E>