de.caff.generics

## Class AbstractBasicUnmodifiableList<T>

- java.lang.Object
- - de.caff.generics.AbstractBasicUnmodifiableList<T>

- All Implemented Interfaces:
    java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>
  Direct Known Subclasses:
    UnmodifiableListArrayWrapper, UnmodifiableListBooleanArrayWrapper, UnmodifiableListByteArrayWrapper, UnmodifiableListDoubleArrayWrapper, UnmodifiableListFloatArrayWrapper, UnmodifiableListIntArrayWrapper, UnmodifiableListLongArrayWrapper, UnmodifiableListShortArrayWrapper

      public abstract class AbstractBasicUnmodifiableList<T>
      extends java.lang.Object
      implements java.util.List<T>

  Basic implementation of an unmodifiable list.
  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractBasicUnmodifiableList()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(int index, T element)` Inserts the specified element at the specified position in this list (optional operation).
    `boolean` | `add(T o)` Appends the specified element to the end of this list (optional operation).
    `boolean` | `addAll(java.util.Collection c)` Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).
    `boolean` | `addAll(int index, java.util.Collection<? extends T> c)` 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).
    `T` | `remove(int index)` Removes the element at the specified position in this list (optional operation).
    `boolean` | `remove(java.lang.Object o)` Removes the first occurrence in this list of the specified element (optional operation).
    `boolean` | `removeAll(java.util.Collection c)` Removes from this list all the elements that are contained in the specified collection (optional operation).
    `boolean` | `retainAll(java.util.Collection c)` Retains only the elements in this list that are contained in the specified collection (optional operation).
    `T` | `set(int index, T element)` Replaces the element at the specified position in this list with the specified element (optional operation).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.List

      `contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, size, sort, spliterator, subList, toArray, toArray`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Constructor Detail

    - #### AbstractBasicUnmodifiableList

          public AbstractBasicUnmodifiableList()

  - ### Method Detail

    - #### 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<T>`
      Specified by:
        `clear` in interface `java.util.List<T>`
      Throws:
        `java.lang.UnsupportedOperationException` - if the `clear` method is not supported by this list.

    - #### remove

          public T 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<T>`
      Parameters:
        `index` - the index of the element to removed.
      Returns:
        the element previously at the specified position.
      Throws:
        `java.lang.UnsupportedOperationException` - if the `remove` method is not supported by this list.
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (index < 0 || index >= size()).

    - #### remove

          public boolean remove(java.lang.Object o)

      Removes the first occurrence in this list of the specified element (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that `(o==null ? get(i)==null : o.equals(get(i)))` (if such an element exists).
      Specified by:
        `remove` in interface `java.util.Collection<T>`
      Specified by:
        `remove` in interface `java.util.List<T>`
      Parameters:
        `o` - element to be removed from this list, if present.
      Returns:
        `true` if this list contained the specified element.
      Throws:
        `java.lang.ClassCastException` - if the type of the specified element is incompatible with this list (optional).
        `java.lang.NullPointerException` - if the specified element is null and this list does not support null elements (optional).
        `java.lang.UnsupportedOperationException` - if the `remove` method is not supported by this list.

    - #### addAll

          public boolean addAll(int index,
                                @NotNull
                                java.util.Collection<? extends T> c)

      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<T>`
      Parameters:
        `index` - index at which to insert first element from the specified collection.
        `c` - elements to be inserted into this list.
      Returns:
        `true` if this list changed as a result of the call.
      Throws:
        `java.lang.UnsupportedOperationException` - if the `addAll` method is not supported by this list.
        `java.lang.ClassCastException` - if the class of one of elements of the specified collection prevents it from being added to this list.
        `java.lang.NullPointerException` - if the specified collection contains one or more null elements and this list does not support null elements, or if the specified collection is `null`.
        `java.lang.IllegalArgumentException` - if some aspect of one of elements of the specified collection prevents it from being added to this list.
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (index < 0 || index > size()).

    - #### addAll

          public boolean addAll(@NotNull
                                java.util.Collection c)

      Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). 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.Collection<T>`
      Specified by:
        `addAll` in interface `java.util.List<T>`
      Parameters:
        `c` - collection whose elements are to be added to this list.
      Returns:
        `true` if this list changed as a result of the call.
      Throws:
        `java.lang.UnsupportedOperationException` - if the `addAll` method is not supported by this list.
        `java.lang.ClassCastException` - if the class of an element in the specified collection prevents it from being added to this list.
        `java.lang.NullPointerException` - if the specified collection contains one or more null elements and this list does not support null elements, or if the specified collection is `null`.
        `java.lang.IllegalArgumentException` - if some aspect of an element in the specified collection prevents it from being added to this list.
      See Also:
        `add(Object)`

    - #### removeAll

          public boolean removeAll(@NotNull
                                   java.util.Collection c)

      Removes from this list all the elements that are contained in the specified collection (optional operation).
      Specified by:
        `removeAll` in interface `java.util.Collection<T>`
      Specified by:
        `removeAll` in interface `java.util.List<T>`
      Parameters:
        `c` - collection that defines which elements will be removed from this list.
      Returns:
        `true` if this list changed as a result of the call.
      Throws:
        `java.lang.UnsupportedOperationException` - if the `removeAll` method is not supported by this list.
        `java.lang.ClassCastException` - if the types of one or more elements in this list are incompatible with the specified collection (optional).
        `java.lang.NullPointerException` - if this list contains one or more null elements and the specified collection does not support null elements (optional). or if the specified collection is `null`.
      See Also:
        `remove(Object)`, `List.contains(Object)`

    - #### retainAll

          public boolean retainAll(@NotNull
                                   java.util.Collection c)

      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<T>`
      Specified by:
        `retainAll` in interface `java.util.List<T>`
      Parameters:
        `c` - collection that defines which elements this set will retain.
      Returns:
        `true` if this list changed as a result of the call.
      Throws:
        `java.lang.UnsupportedOperationException` - if the `retainAll` method is not supported by this list.
        `java.lang.ClassCastException` - if the types of one or more elements in this list are incompatible with the specified collection (optional).
        `java.lang.NullPointerException` - if this list contains one or more null elements and the specified collection does not support null elements (optional). or if the specified collection is `null`.
      See Also:
        `remove(Object)`, `List.contains(Object)`

    - #### set

          public T set(int index,
                       T element)

      Replaces the element at the specified position in this list with the specified element (optional operation).
      Specified by:
        `set` in interface `java.util.List<T>`
      Parameters:
        `index` - index of element to replace.
        `element` - element to be stored at the specified position.
      Returns:
        the element previously at the specified position.
      Throws:
        `java.lang.UnsupportedOperationException` - if the `set` method is not supported by this list.
        `java.lang.ClassCastException` - if the class of the specified element prevents it from being added to this list.
        `java.lang.NullPointerException` - if the specified element is null and this list does not support null elements.
        `java.lang.IllegalArgumentException` - if some aspect of the specified element prevents it from being added to this list.
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (index < 0 || index >= size()).

    - #### add

          public void add(int index,
                          T element)

      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<T>`
      Parameters:
        `index` - index at which the specified element is to be inserted.
        `element` - element to be inserted.
      Throws:
        `java.lang.UnsupportedOperationException` - if the `add` method is not supported by this list.
        `java.lang.ClassCastException` - if the class of the specified element prevents it from being added to this list.
        `java.lang.NullPointerException` - if the specified element is null and this list does not support null elements.
        `java.lang.IllegalArgumentException` - if some aspect of the specified element prevents it from being added to this list.
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (index < 0 || index > size()).

    - #### add

          public boolean add(T o)

      Appends the specified element to the end of this list (optional operation).

      Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.

      Specified by:
        `add` in interface `java.util.Collection<T>`
      Specified by:
        `add` in interface `java.util.List<T>`
      Parameters:
        `o` - element to be appended to this list.
      Returns:
        `true` (as per the general contract of the `Collection.add` method).
      Throws:
        `java.lang.UnsupportedOperationException` - if the `add` method is not supported by this list.
        `java.lang.ClassCastException` - if the class of the specified element prevents it from being added to this list.
        `java.lang.NullPointerException` - if the specified element is null and this list does not support null elements.
        `java.lang.IllegalArgumentException` - if some aspect of this element prevents it from being added to this list.