List which wraps another List but prevents insertion of null elements.
Methods which only perform checks with the element argument (e.g. contains(Object)) do
not throw exceptions for null arguments.
| Modifier and Type | Field and Description |
|---|---|
| private final ArrayList |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(int index, E element)
Overrides java. Implements java. Inserts the specified element at the specified position in this list (optional operation). |
| public void | clear()
Overrides java. Implements java. Removes all of the elements from this list (optional operation). |
| public boolean | contains(Object o)
Overrides java. Implements java. Returns |
| public boolean | equals(Object o)
Overrides java. Implements java. Compares the specified object with this list for equality. |
| public E | get(int index)
Implements abstract java. Implements java. Returns the element at the specified position in this list. |
| public int | hashCode()
Overrides java. Implements java. Returns the hash code value for this list. |
| public int | indexOf(Object o)
Overrides java. Implements java. Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. |
| public int | lastIndexOf(Object o)
Overrides java. Implements java. Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. |
| private E | |
| public E | remove(int index)
Overrides java. Implements java. Removes the element at the specified position in this list (optional operation). |
| public boolean | remove(Object o)
Overrides java. Implements java. Removes the first occurrence of the specified element from this list, if it is present (optional operation). |
| public boolean | removeAll(Collection<?> c)
Overrides java. Implements java. Removes from this list all of its elements that are contained in the specified collection (optional operation). |
| public boolean | retainAll(Collection<?> c)
Overrides java. Implements java. Retains only the elements in this list that are contained in the specified collection (optional operation). |
| public E | set(int index, E element)
Overrides java. Implements java. Replaces the element at the specified position in this list with the specified element (optional operation). |
| public int | size()
Implements abstract java. Implements java. Returns the number of elements in this list. |
| public Object[] | toArray()
Overrides java. Implements java. Returns an array containing all of the elements in this list in proper sequence (from first to last element). |
| public <T> T[] | toArray(T[] a)
Overrides java. Implements java. Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. |
| delegate | back to summary |
|---|---|
| private final ArrayList<E> delegate | |
| NonNullElementWrapperList | back to summary |
|---|---|
public NonNullElementWrapperList(ArrayList<E> delegate)
| |
| add | back to summary |
|---|---|
| public void add(int index, E element) Overrides java. Implements java. Doc from java. 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).
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this list (optional operation). The list will be empty after this call returns.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Object o) Overrides java. Implements java. Doc from java. Returns
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| get | back to summary |
|---|---|
| public E get(int index) Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list.
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(Object o) Overrides java. Implements java. Doc from java. 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
| |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(Object o) Overrides java. Implements java. Doc from java. 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
| |
| nonNull | back to summary |
|---|---|
| private E nonNull(E element) | |
| remove | back to summary |
|---|---|
| public E remove(int index) Overrides java. Implements java. Doc from java. 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.
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object o) Overrides java. Implements java. Doc from java. Removes the first occurrence of the specified element from this list,
if it is present (optional operation). If this list does not contain
the element, it is unchanged. More formally, removes the element with
the lowest index
| |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> c) Overrides java. Implements java. Doc from java. Removes from this list all of its elements that are contained in the specified collection (optional operation).
| |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> c) Overrides java. Implements java. Doc from java. Retains only the elements in this list that are contained in the specified collection (optional operation). In other words, removes from this list all of its elements that are not contained in the specified collection.
| |
| set | back to summary |
|---|---|
| public E set(int index, E element) Overrides java. Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |
| toArray | back to summary |
|---|---|
| public Object[] toArray() Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this list in proper sequence (from first to last element). The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs.
| |
| toArray | back to summary |
|---|---|
| public <T> T[] toArray(T[] a) Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list. If the list fits in the specified array with room to spare (i.e.,
the array has more elements than the list), the element in the array
immediately following the end of the list is set to Like the Suppose
Note that toArray(new Object[0]) is identical in function to
toArray().
| |