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 class
PersistedList.ConverterImpl
Converter
implementation for XStream.
-
Field Summary
Fields Modifier and Type Field Description protected CopyOnWriteList<T>
data
protected Saveable
owner
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PersistedList()
PersistedList(Saveable owner)
protected
PersistedList(Collection<? extends T> initialList)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T item)
boolean
addAll(Collection<? extends T> items)
void
addAllTo(Collection<? super T> dst)
void
clear()
boolean
contains(Object item)
T
get(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.boolean
isEmpty()
Iterator<T>
iterator()
protected void
onModified()
Called when a list is mutated.void
remove(Class<? extends T> type)
Removes an instance by its type.boolean
remove(Object o)
void
removeAll(Class<? extends T> type)
void
replace(T from, T to)
A convenience method to replace a single item.void
replaceBy(Collection<? extends T> col)
void
setOwner(Saveable owner)
int
size()
<X> X[]
toArray(X[] array)
Gets all theDescribable
s in an array.List<T>
toList()
Returns the snapshot view of instances as list.String
toString()
-
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:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceList<T>
- Overrides:
add
in classAbstractList<T>
-
addAll
@WithBridgeMethods(void.class) public boolean addAll(Collection<? extends T> items)
- Specified by:
addAll
in interfaceCollection<T>
- Specified by:
addAll
in interfaceList<T>
- Overrides:
addAll
in 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:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceList<T>
- Specified by:
size
in 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:
remove
in interfaceCollection<T>
- Specified by:
remove
in interfaceList<T>
- Overrides:
remove
in classAbstractCollection<T>
-
removeAll
public void removeAll(Class<? extends T> type) throws IOException
- Throws:
IOException
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<T>
- Specified by:
clear
in interfaceList<T>
- Overrides:
clear
in classAbstractList<T>
-
onModified
protected void onModified() throws IOException
Called when a list is mutated.- Throws:
IOException
-
toArray
public <X> X[] toArray(X[] array)
Gets all theDescribable
s in an array.- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceList<T>
- Overrides:
toArray
in classAbstractCollection<T>
-
addAllTo
public void addAllTo(Collection<? super T> dst)
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<T>
- Specified by:
isEmpty
in interfaceList<T>
- Overrides:
isEmpty
in classAbstractCollection<T>
-
contains
public boolean contains(Object item)
- Specified by:
contains
in interfaceCollection<T>
- Specified by:
contains
in interfaceList<T>
- Overrides:
contains
in classAbstractCollection<T>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<T>
-
-