Class CollectionsExt.ImmutableList<E>

  • Type Parameters:
    E - the class of the elements of this list.
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>
    Enclosing class:
    CollectionsExt<E>

    public static final class CollectionsExt.ImmutableList<E>
    extends CollectionsExt.AbstractImmutableCollection<java.util.List<E>,​E>
    implements java.util.List<E>
    A list which prevents being modified by throwing an exception for the modifying methods.
    • Field Detail

      • list

        private final java.util.List<E> list
        The enclosed list containing the elements of this list.
    • Constructor Detail

      • ImmutableList

        ImmutableList​(java.util.List<E> list)
    • Method Detail

      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> coll)
        Specified by:
        addAll in interface java.util.List<E>
        Throws:
        java.lang.UnsupportedOperationException - if either unrestricted() does not allow this operation or AddObj is no allowed operation according to CollectionsExt.AbstractImmutableCollection.allowedModifications(). In the latter case it does not matter, whether effectively it is tried to add objects which is the case only coll is not empty.
      • get

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

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.List<E>
        Overrides:
        hashCode in class java.lang.Object
      • equals

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

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

        public int lastIndexOf​(java.lang.Object obj)
        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>
      • set

        public E set​(int index,
                     E element)
        Specified by:
        set in interface java.util.List<E>
        Throws:
        java.lang.UnsupportedOperationException - if either unrestricted() does not allow this operation or SetObj is no allowed operation according to CollectionsExt.AbstractImmutableCollection.allowedModifications(). In the latter case it does not matter, whether effectively it is tried to set an object which is the case only if element is not at place index in this.
      • replaceAll

        public void replaceAll​(java.util.function.UnaryOperator<E> operator)
        Specified by:
        replaceAll in interface java.util.List<E>
        Throws:
        java.lang.UnsupportedOperationException - if either unrestricted() does not allow this operation or SetObj is no allowed operation according to CollectionsExt.AbstractImmutableCollection.allowedModifications(). In the latter case it does not matter, whether effectively it is tried to replace an object which is the case only if operator really changes an object.
      • sort

        public void sort​(java.util.Comparator<? super E> cmp)
        Specified by:
        sort in interface java.util.List<E>
        Throws:
        java.lang.UnsupportedOperationException - if either unrestricted() does not allow this operation or SetObj is no allowed operation according to CollectionsExt.AbstractImmutableCollection.allowedModifications(). In the latter case it does not matter, whether effectively it is tried to replace an object which is the case only if this is not completely sorted according to cmp. This definition is in conjunction with the requirement, of List.sort(Comparator) that this exception is thrown iff the list iterator does not permit the ListIterator.set(Object) method.
      • subList

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