hudson.util
Class PersistedList<T>

java.lang.Object
  extended by hudson.util.PersistedList<T>
All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
DescribableList

public class PersistedList<T>
extends Object
implements Iterable<T>

Collection whose change is notified to the parent object for persistence.

Since:
1.MULTISOURCE
Author:
Kohsuke Kawaguchi

Nested Class Summary
static class PersistedList.ConverterImpl
          Converter implementation for XStream.
 
Field Summary
protected  CopyOnWriteList<T> data
           
protected  Saveable owner
           
 
Constructor Summary
protected PersistedList()
           
protected PersistedList(Collection<? extends T> initialList)
           
  PersistedList(Saveable owner)
           
 
Method Summary
 void add(T item)
           
 void addAll(Collection<? extends T> items)
           
 void addAllTo(Collection<? super T> dst)
           
 void clear()
           
 boolean contains(Object item)
           
<U extends T>
U
get(Class<U> type)
           
 T get(int index)
           
<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(T 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()
           
 T[] toArray(T[] array)
          Gets all the Describables in an array.
 List<T> toList()
          Returns the snapshot view of instances as list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

public void add(T item)
         throws IOException
Throws:
IOException

addAll

public void addAll(Collection<? extends T> items)
            throws IOException
Throws:
IOException

replaceBy

public void replaceBy(Collection<? extends T> col)
               throws IOException
Throws:
IOException

get

public T get(int index)

get

public <U extends T> U get(Class<U> type)

getAll

public <U extends T> List<U> getAll(Class<U> type)
Gets all instances that matches the given type.


size

public int size()

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(T o)
               throws IOException
Throws:
IOException

removeAll

public void removeAll(Class<? extends T> type)
               throws IOException
Throws:
IOException

clear

public void clear()

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>

onModified

protected void onModified()
                   throws IOException
Called when a list is mutated.

Throws:
IOException

toList

public List<T> toList()
Returns the snapshot view of instances as list.


toArray

public T[] toArray(T[] array)
Gets all the Describables in an array.


addAllTo

public void addAllTo(Collection<? super T> dst)

isEmpty

public boolean isEmpty()

contains

public boolean contains(Object item)


Copyright © 2004-2013. All Rights Reserved.