Package com.globalmentor.collections
Class ObjectList<E>
- java.lang.Object
-
- com.globalmentor.collections.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 withCollections.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 specifiedfromIndex
, inclusive, andtoIndex
, exclusive.java.lang.Object[]
toArray()
Deprecated.<T> T[]
toArray(T[] a)
Deprecated.java.lang.String
toString()
Deprecated.
-
-
-
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 isnull
.
-
-
Method Detail
-
size
public int size()
Deprecated.
-
isEmpty
public boolean isEmpty()
Deprecated.
-
contains
public boolean contains(java.lang.Object o)
Deprecated.
-
iterator
public java.util.Iterator<E> iterator()
Deprecated.
-
toArray
public java.lang.Object[] toArray()
Deprecated.
-
toArray
public <T> T[] toArray(T[] a)
Deprecated.
-
add
public boolean add(E e)
Deprecated.
-
remove
public boolean remove(java.lang.Object o)
Deprecated.
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
Deprecated.
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
Deprecated.
-
addAll
public boolean addAll(int index, java.util.Collection<? extends E> c)
Deprecated.- Specified by:
addAll
in interfacejava.util.List<E>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
Deprecated.
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
Deprecated.
-
clear
public void clear()
Deprecated.
-
get
public E get(int index)
Deprecated.Returns the element at the specified position in this list.- Specified by:
get
in interfacejava.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 interfacejava.util.List<E>
- Parameters:
index
- index of the element to replaceelement
- element to be stored at the specified position- Returns:
- the element previously at the specified position
- Throws:
java.lang.UnsupportedOperationException
- if theset
operation is not supported by this listjava.lang.ClassCastException
- if the class of the specified element prevents it from being added to this listjava.lang.NullPointerException
- if the specified element is null and this list does not permit null elementsjava.lang.IllegalArgumentException
- if some property of the specified element prevents it from being added to this listjava.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 interfacejava.util.List<E>
- Parameters:
index
- index at which the specified element is to be insertedelement
- element to be inserted- Throws:
java.lang.UnsupportedOperationException
- if theadd
operation is not supported by this listjava.lang.ClassCastException
- if the class of the specified element prevents it from being added to this listjava.lang.NullPointerException
- if the specified element is null and this list does not permit null elementsjava.lang.IllegalArgumentException
- if some property of the specified element prevents it from being added to this listjava.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 interfacejava.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 theremove
operation is not supported by this listjava.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 indexi
such that(o==null ? get(i)==null : o.equals(get(i)))
, or -1 if there is no such index.- Specified by:
indexOf
in interfacejava.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 indexi
such that(o==null ? get(i)==null : o.equals(get(i)))
, or -1 if there is no such index.- Specified by:
lastIndexOf
in interfacejava.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 interfacejava.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 tonext
. An initial call toprevious
would return the element with the specified index minus one.- Specified by:
listIterator
in interfacejava.util.List<E>
- Parameters:
index
- index of first element to be returned from the list iterator (by a call to thenext
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 specifiedfromIndex
, inclusive, andtoIndex
, exclusive. (IffromIndex
andtoIndex
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 forindexOf
andlastIndexOf
, and all of the algorithms in theCollections
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 interfacejava.util.List<E>
- Parameters:
fromIndex
- low endpoint (inclusive) of the subListtoIndex
- 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.
-
hashCode
public int hashCode()
Deprecated.
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toString
in classjava.lang.Object
-
-