Class AttachmentList<E>
- java.lang.Object
-
- org.jboss.as.server.deployment.AttachmentList<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,RandomAccess
public final class AttachmentList<E> extends Object implements List<E>, RandomAccess
AListmeant for use with anAttachableobject. The list has concurrency semantics equivalent toCollections.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:AttachmentList
list = new AttachmentList<>()>; ... synchronized (list) { Iterator i = list.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); } - Author:
- David M. Lloyd
-
-
Constructor Summary
Constructors Constructor Description AttachmentList(int initialCapacity, Class<E> valueClass)Creates a newAttachmentList.AttachmentList(Class<E> valueClass)Creates a newAttachmentList.AttachmentList(Collection<? extends E> c, Class<E> valueClass)Creates a newAttachmentList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E element)booleanadd(E e)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanequals(Object o)voidforEach(Consumer<? super E> action)Eget(int index)Class<E>getValueClass()inthashCode()intindexOf(Object o)booleanisEmpty()Iterator<E>iterator()intlastIndexOf(Object o)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)Stream<E>parallelStream()Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanremoveIf(Predicate<? super E> filter)voidreplaceAll(UnaryOperator<E> operator)booleanretainAll(Collection<?> c)Eset(int index, E element)intsize()voidsort(Comparator<? super E> c)Spliterator<E>spliterator()Stream<E>stream()List<E>subList(int fromIndex, int toIndex)Object[]toArray()<T> T[]toArray(T[] a)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
toArray
-
-
-
-
Constructor Detail
-
AttachmentList
public AttachmentList(int initialCapacity, Class<E> valueClass)Creates a newAttachmentList.- Parameters:
initialCapacity- the initial capacity of the listvalueClass- the type of element the list is permitted to hold
-
AttachmentList
public AttachmentList(Class<E> valueClass)
Creates a newAttachmentList.- Parameters:
valueClass- the type of element the list is permitted to hold
-
AttachmentList
public AttachmentList(Collection<? extends E> c, Class<E> valueClass)
Creates a newAttachmentList.- Parameters:
c- initial contents of the list. Cannot benullvalueClass- the type of element the list is permitted to hold
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
iterator
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.
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
add
public boolean add(E e)
-
remove
public boolean remove(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
removeAll
public boolean removeAll(Collection<?> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
clear
public void clear()
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
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.
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
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.
- Specified by:
listIteratorin interfaceList<E>
-
removeIf
public boolean removeIf(Predicate<? super E> filter)
- Specified by:
removeIfin interfaceCollection<E>
-
replaceAll
public void replaceAll(UnaryOperator<E> operator)
- Specified by:
replaceAllin interfaceList<E>
-
sort
public void sort(Comparator<? super E> c)
-
spliterator
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.- Specified by:
spliteratorin interfaceCollection<E>- Specified by:
spliteratorin interfaceIterable<E>- Specified by:
spliteratorin interfaceList<E>
-
stream
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.- Specified by:
streamin interfaceCollection<E>
-
parallelStream
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.- Specified by:
parallelStreamin interfaceCollection<E>
-
-