Class SynchronizedListDecorator<E>

  • Type Parameters:
    E - The type of element contained in the list.
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>

    public class SynchronizedListDecorator<E>
    extends SynchronizedCollectionDecorator<E>
    implements java.util.List<E>
    A list that wraps an existing list, providing access through the List interface. All collection access is synchronized on the provided synchronization object.
    Author:
    Garret Wilson
    • Field Detail

      • list

        protected final java.util.List<E> list
        The list this class decorates.
    • Constructor Detail

      • SynchronizedListDecorator

        public SynchronizedListDecorator​(java.util.List<E> list,
                                         java.lang.Object mutex)
        List constructor.
        Parameters:
        list - The list this list should decorate.
        mutex - The mutual exclusion synchronization object.
        Throws:
        java.lang.NullPointerException - if the provided list and/or mutex is null.
    • Method Detail

      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.List<E>
      • replaceAll

        public void replaceAll​(java.util.function.UnaryOperator<E> operator)
        Specified by:
        replaceAll in interface java.util.List<E>
      • sort

        public void sort​(java.util.Comparator<? super E> c)
        Specified by:
        sort in interface java.util.List<E>
      • get

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

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

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

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

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<E>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<E>
      • listIterator

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

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

        public java.util.List<E> subList​(int fromIndex,
                                         int toIndex)
        Specified by:
        subList in interface java.util.List<E>