Package hudson.util
Class PersistedList<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<T>
-
- hudson.util.PersistedList<T>
-
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>
- Direct Known Subclasses:
DescribableList
public class PersistedList<T> extends AbstractList<T>
Collection whose change is notified to the parent object for persistence.- Since:
- 1.333
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPersistedList.ConverterImplConverterimplementation for XStream.
-
Field Summary
Fields Modifier and Type Field Description protected CopyOnWriteList<T>dataprotected Saveableowner-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPersistedList()PersistedList(Saveable owner)protectedPersistedList(Collection<? extends T> initialList)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T item)booleanaddAll(Collection<? extends T> items)voidaddAllTo(Collection<? super T> dst)voidclear()booleancontains(Object item)Tget(int index)<U extends T>
Uget(Class<U> type)<U extends T>
List<U>getAll(Class<U> type)Gets all instances that matches the given type.booleanisEmpty()Iterator<T>iterator()protected voidonModified()Called when a list is mutated.voidremove(Class<? extends T> type)Removes an instance by its type.booleanremove(Object o)voidremoveAll(Class<? extends T> type)voidreplace(T from, T to)A convenience method to replace a single item.voidreplaceBy(Collection<? extends T> col)voidsetOwner(Saveable owner)intsize()<X> X[]toArray(X[] array)Gets all theDescribables in an array.List<T>toList()Returns the snapshot view of instances as list.StringtoString()-
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toArray
-
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.util.List
containsAll, removeAll, replaceAll, retainAll, sort, spliterator, toArray
-
-
-
-
Field Detail
-
data
protected final CopyOnWriteList<T> data
-
owner
protected Saveable owner
-
-
Constructor Detail
-
PersistedList
protected PersistedList()
-
PersistedList
protected PersistedList(Collection<? extends T> initialList)
-
PersistedList
public PersistedList(Saveable owner)
-
-
Method Detail
-
setOwner
public void setOwner(Saveable owner)
-
add
@WithBridgeMethods(void.class) public boolean add(T item)
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceList<T>- Overrides:
addin classAbstractList<T>
-
addAll
@WithBridgeMethods(void.class) public boolean addAll(Collection<? extends T> items)
- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceList<T>- Overrides:
addAllin classAbstractCollection<T>
-
replaceBy
public void replaceBy(Collection<? extends T> col) throws IOException
- Throws:
IOException
-
get
public T get(int index)
-
getAll
public <U extends T> List<U> getAll(Class<U> type)
Gets all instances that matches the given type.
-
size
public int size()
- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein classAbstractCollection<T>
-
remove
public void remove(Class<? extends T> type) throws IOException
Removes an instance by its type.- Throws:
IOException
-
replace
public void replace(T from, T to) throws IOException
A convenience method to replace a single item. This method shouldn't be used when you are replacing a lot of stuff as copy-on-write semantics make this rather slow.- Throws:
IOException
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceList<T>- Overrides:
removein classAbstractCollection<T>
-
removeAll
public void removeAll(Class<? extends T> type) throws IOException
- Throws:
IOException
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceList<T>- Overrides:
clearin classAbstractList<T>
-
onModified
protected void onModified() throws IOExceptionCalled when a list is mutated.- Throws:
IOException
-
toArray
public <X> X[] toArray(X[] array)
Gets all theDescribables in an array.- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceList<T>- Overrides:
toArrayin classAbstractCollection<T>
-
addAllTo
public void addAllTo(Collection<? super T> dst)
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceList<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
contains
public boolean contains(Object item)
- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceList<T>- Overrides:
containsin classAbstractCollection<T>
-
toString
public String toString()
- Overrides:
toStringin classAbstractCollection<T>
-
-