public final class AttachmentList<E> extends Object implements List<E>, RandomAccess
List meant for use with an Attachable object. The list has concurrency semantics equivalent to
Collections.synchronizedList; i.e. it is thread safe for reads and writes not involving an iterator or stream
but if reads can occur concurrently with writes it is imperative that the user manually synchronize on the list
when iterating over it:
AttachmentListlist = new AttachmentList<>()>; ... synchronized (list) { Iterator i = list.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); }
| Constructor and Description |
|---|
AttachmentList(Class<E> valueClass)
Creates a new
AttachmentList. |
AttachmentList(Collection<? extends E> c,
Class<E> valueClass)
Creates a new
AttachmentList. |
AttachmentList(int initialCapacity,
Class<E> valueClass)
Creates a new
AttachmentList. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
void |
add(int index,
E element) |
boolean |
addAll(Collection<? extends E> c) |
boolean |
addAll(int index,
Collection<? extends E> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object o) |
void |
forEach(Consumer<? super E> action) |
E |
get(int index) |
Class<E> |
getValueClass() |
int |
hashCode() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
Stream<E> |
parallelStream() |
E |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
removeIf(Predicate<? super E> filter) |
void |
replaceAll(UnaryOperator<E> operator) |
boolean |
retainAll(Collection<?> c) |
E |
set(int index,
E element) |
int |
size() |
void |
sort(Comparator<? super E> c) |
Spliterator<E> |
spliterator() |
Stream<E> |
stream() |
List<E> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
public AttachmentList(int initialCapacity,
Class<E> valueClass)
AttachmentList.initialCapacity - the initial capacity of the listvalueClass - the type of element the list is permitted to holdpublic AttachmentList(Class<E> valueClass)
AttachmentList.valueClass - the type of element the list is permitted to holdpublic AttachmentList(Collection<? extends E> c, Class<E> valueClass)
AttachmentList.c - initial contents of the list. Cannot be nullvalueClass - the type of element the list is permitted to holdpublic int size()
public boolean isEmpty()
public boolean contains(Object o)
public Iterator<E> iterator()
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when iterating over it.
public Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean add(E e)
public boolean remove(Object o)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in interface List<E>public boolean addAll(Collection<? extends E> c)
public boolean addAll(int index,
Collection<? extends E> c)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public void clear()
public boolean equals(Object o)
public int hashCode()
public int lastIndexOf(Object o)
lastIndexOf in interface List<E>public ListIterator<E> listIterator()
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when iterating over it.
listIterator in interface List<E>public ListIterator<E> listIterator(int index)
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when iterating over it.
listIterator in interface List<E>public boolean removeIf(Predicate<? super E> filter)
removeIf in interface Collection<E>public void replaceAll(UnaryOperator<E> operator)
replaceAll in interface List<E>public void sort(Comparator<? super E> c)
public Spliterator<E> spliterator()
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list
when using the Spliterator.
spliterator in interface Iterable<E>spliterator in interface Collection<E>spliterator in interface List<E>public Stream<E> stream()
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list
when using the Stream.
stream in interface Collection<E>public Stream<E> parallelStream()
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list
when using the Stream.
parallelStream in interface Collection<E>Copyright © 2021 JBoss by Red Hat. All rights reserved.