Class ObjectList<E>

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

    @Deprecated
    public class ObjectList<E>
    extends java.lang.Object
    implements java.util.List<E>, ImmutableCollection<E>
    Deprecated.
    Replace with Collections.singletonList(Object).
    A read-only list containing a single object.
    Author:
    Garret Wilson
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectList​(E object)
      Deprecated.
      Object constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void add​(int index, E element)
      Deprecated.
      Inserts the specified element at the specified position in this list (optional operation).
      boolean add​(E e)
      Deprecated.
      boolean addAll​(int index, java.util.Collection<? extends E> c)
      Deprecated.
      boolean addAll​(java.util.Collection<? extends E> c)
      Deprecated.
      void clear()
      Deprecated.
      boolean contains​(java.lang.Object o)
      Deprecated.
      boolean containsAll​(java.util.Collection<?> c)
      Deprecated.
      boolean equals​(java.lang.Object o)
      Deprecated.
      E get​(int index)
      Deprecated.
      Returns the element at the specified position in this list.
      int hashCode()
      Deprecated.
      int indexOf​(java.lang.Object o)
      Deprecated.
      Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
      boolean isEmpty()
      Deprecated.
      java.util.Iterator<E> iterator()
      Deprecated.
      int lastIndexOf​(java.lang.Object o)
      Deprecated.
      Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
      java.util.ListIterator<E> listIterator()
      Deprecated.
      Returns a list iterator over the elements in this list (in proper sequence).
      java.util.ListIterator<E> listIterator​(int index)
      Deprecated.
      Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
      E remove​(int index)
      Deprecated.
      Removes the element at the specified position in this list (optional operation).
      boolean remove​(java.lang.Object o)
      Deprecated.
      boolean removeAll​(java.util.Collection<?> c)
      Deprecated.
      boolean retainAll​(java.util.Collection<?> c)
      Deprecated.
      E set​(int index, E element)
      Deprecated.
      Replaces the element at the specified position in this list with the specified element (optional operation).
      int size()
      Deprecated.
      java.util.List<E> subList​(int fromIndex, int toIndex)
      Deprecated.
      Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
      java.lang.Object[] toArray()
      Deprecated.
      <T> T[] toArray​(T[] a)
      Deprecated.
      java.lang.String toString()
      Deprecated.
       
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        replaceAll, sort, spliterator
    • Constructor Detail

      • ObjectList

        public ObjectList​(E object)
        Deprecated.
        Object constructor.
        Parameters:
        object - The object to hold in the list.
        Throws:
        java.lang.NullPointerException - if the given object is null.
    • Method Detail

      • size

        public int size()
        Deprecated.
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.List<E>
      • isEmpty

        public boolean isEmpty()
        Deprecated.
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.List<E>
      • contains

        public boolean contains​(java.lang.Object o)
        Deprecated.
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.List<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Deprecated.
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.List<E>
      • toArray

        public java.lang.Object[] toArray()
        Deprecated.
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
      • toArray

        public <T> T[] toArray​(T[] a)
        Deprecated.
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
      • add

        public boolean add​(E e)
        Deprecated.
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
      • remove

        public boolean remove​(java.lang.Object o)
        Deprecated.
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.List<E>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Deprecated.
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface java.util.List<E>
      • addAll

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

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

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

        public boolean removeAll​(java.util.Collection<?> c)
        Deprecated.
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.List<E>
      • clear

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

        public E get​(int index)
        Deprecated.
        Returns the element at the specified position in this list.
        Specified by:
        get in interface java.util.List<E>
        Parameters:
        index - index of the element to return
        Returns:
        the element at the specified position in this list
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
      • set

        public E set​(int index,
                     E element)
        Deprecated.
        Replaces the element at the specified position in this list with the specified element (optional operation).
        Specified by:
        set in interface java.util.List<E>
        Parameters:
        index - index of the 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 operation 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 permit null elements
        java.lang.IllegalArgumentException - if some property 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,
                        E element)
        Deprecated.
        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<E>
        Parameters:
        index - index at which the specified element is to be inserted
        element - element to be inserted
        Throws:
        java.lang.UnsupportedOperationException - if the add operation 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 permit null elements
        java.lang.IllegalArgumentException - if some property 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())
      • remove

        public E remove​(int index)
        Deprecated.
        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<E>
        Parameters:
        index - the index of the element to be removed
        Returns:
        the element previously at the specified position
        Throws:
        java.lang.UnsupportedOperationException - if the remove operation is not supported by this list
        java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
      • indexOf

        public int indexOf​(java.lang.Object o)
        Deprecated.
        Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
        Specified by:
        indexOf in interface java.util.List<E>
        Parameters:
        o - element to search for
        Returns:
        the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the 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 permit null elements (optional)
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Deprecated.
        Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
        Specified by:
        lastIndexOf in interface java.util.List<E>
        Parameters:
        o - element to search for
        Returns:
        the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the 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 permit null elements (optional)
      • listIterator

        public java.util.ListIterator<E> listIterator()
        Deprecated.
        Returns a list iterator over the elements in this list (in proper sequence).
        Specified by:
        listIterator in interface java.util.List<E>
        Returns:
        a list iterator over the elements in this list (in proper sequence)
      • listIterator

        public java.util.ListIterator<E> listIterator​(int index)
        Deprecated.
        Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.
        Specified by:
        listIterator in interface java.util.List<E>
        Parameters:
        index - index of first element to be returned from the list iterator (by a call to the next method)
        Returns:
        a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())
      • subList

        public java.util.List<E> subList​(int fromIndex,
                                         int toIndex)
        Deprecated.
        Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

        This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:

         list.subList(from, to).clear();
         
        Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList.

        The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

        Specified by:
        subList in interface java.util.List<E>
        Parameters:
        fromIndex - low endpoint (inclusive) of the subList
        toIndex - high endpoint (exclusive) of the subList
        Returns:
        a view of the specified range within this list
        Throws:
        java.lang.IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex)
      • equals

        public boolean equals​(java.lang.Object o)
        Deprecated.
        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
      • hashCode

        public int hashCode()
        Deprecated.
        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
      • toString

        public java.lang.String toString()
        Deprecated.
        Overrides:
        toString in class java.lang.Object