Class ListModel<E>

All Implemented Interfaces:
IEditableModel, IModel, IList<E>, IValidable, Iterable<E>, Collection<E>, List<E>
Direct Known Subclasses:
BmList, EmfList, ListWorkingCopy, PojoList, ViewModelList

public abstract class ListModel<E> extends EditableModel implements IList<E>
Base list model implementation.
  • Constructor Details

    • ListModel

      public ListModel()
  • Method Details

    • discard

      public void discard()
      Description copied from interface: IModel
      Discards the changes stored in the model buffer since last IModel.commit() operation.
      Specified by:
      discard in interface IModel
      Overrides:
      discard in class Model
    • isEqual

      public boolean isEqual(List<E> other)
      Description copied from interface: IList
      Checks the list for equality with the current stored list.
      Specified by:
      isEqual in interface IList<E>
      Parameters:
      other - the other list to check.
      Returns:
      true if other list is equal to this list, false otherwise.
    • addListListener

      public void addListListener(IListListener<E> listener)
      Description copied from interface: IList
      Adds the list listener.
      Specified by:
      addListListener in interface IList<E>
      Parameters:
      listener - the listener to add.
    • removeListListener

      public void removeListListener(IListListener<E> listener)
      Description copied from interface: IList
      Removes the list listener.
      Specified by:
      removeListListener in interface IList<E>
      Parameters:
      listener - the listener to remove.
    • createWorkingCopy

      public IList<E> createWorkingCopy()
      Specified by:
      createWorkingCopy in interface IList<E>
      Specified by:
      createWorkingCopy in interface IModel
      Overrides:
      createWorkingCopy in class Model
      Returns:
      the model working copy or null if working copies is not supported by the model.
    • dispose

      public void dispose()
      Description copied from interface: IModel
      Disposes this model.
      Specified by:
      dispose in interface IModel
      Overrides:
      dispose in class Model
    • 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)
      Removes the first occurrence of the specified element from this list, if it is present. But if o == null, removes all null elements from this list. If the list does not contain the element, it is unchanged. Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).
      Specified by:
      remove in interface Collection<E>
      Specified by:
      remove in interface List<E>
      Parameters:
      o - element to be removed from this list, if present
      Returns:
      true if this list contained the specified element
    • 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>
    • fill

      public void fill(Collection<E> collection)
      Description copied from interface: IList
      Clears the current stored list and adds all elements of the given collection to the stored list.
      Specified by:
      fill in interface IList<E>
      Parameters:
      collection - the collection to add.
    • toString

      public String toString()
      Overrides:
      toString in class Model
    • queueNotifyListChanged

      protected void queueNotifyListChanged()
      Queues the runnable that notifies the listeners about a change of this list. In fact it queues a runnable that performs notifyListChanged(ChangeOrigin).
    • getCommittedList

      protected final List<E> getCommittedList()
      Returns:
      the committed list, under normal conditions it should be in sync with data source.
    • getUncommittedList

      protected final List<E> getUncommittedList()
      Returns:
      the buffered but yet uncommitted list.
    • setCommittedList

      protected final void setCommittedList(List<E> list)
      Sets the committed with the new value.
      Parameters:
      list - the new committed list to set.
    • setUncommitedList

      protected final void setUncommitedList(List<E> list)
      Sets the uncommitted with the new value.
      Parameters:
      list - the new uncommitted list to set.
    • setList

      protected final void setList(List<E> list)
      Makes copies of the given list and sets both committed and uncommitted lists at the same time.
      Parameters:
      list - the list to set.
    • notifyListChanged

      protected final void notifyListChanged(ChangeOrigin changeOrigin)
      Notifies the listeners about a change of this list.
    • isElementEqual

      protected boolean isElementEqual(E e1, E e2)
      Checks the equality of the two elements of the list.
      Parameters:
      e1 - the first element
      e2 - the second element
      Returns:
      true if the elements are equals, otherwise - false.