Top Description Inners Fields Constructors Methods
groovy.util

public Class ObservableList

extends Object
implements List
Class Inheritance
All Implemented Interfaces
java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Imports
groovy.lang.Closure, java.beans.PropertyChangeEvent, .PropertyChangeListener, .PropertyChangeSupport, java.util.ArrayList, .Collection, .Collections, .HashSet, .Iterator, .List, .ListIterator, .Set

List decorator that will trigger PropertyChangeEvents when a value changes.
An optional Closure may be specified and will work as a filter, if it returns true the property will trigger an event (if the value indeed changed), otherwise it won't. The Closure may receive 1 or 2 parameters, the single one being the value, the other one both the key and value, for example:
// skip all properties whose value is a closure
def map = new ObservableList( {!(it instanceof Closure)} )

// skip all properties whose name matches a regex
def map = new ObservableList( { name, value -> !(name =˜ /[A-Z+]/) } )
The current implementation will trigger specialized events in the following scenarios, you need not register a different listener as those events extend from PropertyChangeEvent

Bound properties

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static class
public static class
public abstract static class
public static class
public static class
public static class
public static class
protected class
protected class

Field Summary

Modifier and TypeField and Description
public static final String
private final List<E>
private final PropertyChangeSupport
public static final String
private final Closure<V>

Constructor Summary

AccessConstructor and Description
public
public
ObservableList(List<E> delegate)

public
public
ObservableList(List<E> delegate, Closure<V> test)

Method Summary

Modifier and TypeMethod and Description
public void
add(int
index at which the specified element is to be inserted
index
,
Object
element to be inserted
element
)

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).
public boolean
add(Object
element to be appended to this list
o
)

Implements java.util.List.add.

Appends the specified element to the end of this list (optional operation).
public boolean
addAll(Collection<E>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).
public boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<E>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
public void
public void
public void
clear()

Implements java.util.List.clear.

Removes all of the elements from this list (optional operation).
public boolean
contains(Object
element whose presence in this list is to be tested
o
)

Implements java.util.List.contains.

Returns true if this list contains the specified element.
public boolean
containsAll(Collection<E>
collection to be checked for containment in this list
c
)

Implements java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.
public boolean
equals(Object
the object to be compared for equality with this list
o
)

Overrides java.lang.Object.equals.

Implements java.util.List.equals.

Compares the specified object with this list for equality.
private void
fireAddWithTest(Object element, int index, int oldSize)

protected void
fireElementAddedEvent(int index, Object element)

protected void
protected void
protected void
fireElementRemovedEvent(int index, Object element)

protected void
fireElementUpdatedEvent(int index, Object oldValue, Object newValue)

protected void
fireMultiElementAddedEvent(int index, List<E> values)

protected void
protected void
fireSizeChangedEvent(int oldValue, int newValue)

public Object
get(int
index of the element to return
index
)

Implements java.util.List.get.

Returns the element at the specified position in this list.
public List<E>
protected List<E>
public PropertyChangeListener[]
public PropertyChangeListener[]
public int
protected Closure<V>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.List.hashCode.

Returns the hash code value for this list.
public boolean
hasListeners(String propertyName)

public int
indexOf(Object
element to search for
o
)

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
public boolean
isEmpty()

Implements java.util.List.isEmpty.

Returns true if this list contains no elements.
public Iterator<E>
iterator()

Implements java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.
public int
lastIndexOf(Object
element to search for
o
)

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
public ListIterator<E>
listIterator()

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).
public ListIterator<E>
listIterator(int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
public Object
remove(int
the index of the element to be removed
index
)

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).
public boolean
remove(Object
element to be removed from this list, if present
o
)

Implements java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).
public boolean
removeAll(Collection<E>
collection containing elements to be removed from this list
c
)

Implements java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).
public void
public void
public boolean
retainAll(Collection<E>
collection containing elements to be retained in this list
c
)

Implements java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation).
public Object
set(int
index of the element to replace
index
,
Object
element to be stored at the specified position
element
)

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
public int
size()

Implements java.util.List.size.

Returns the number of elements in this list.
public List<E>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
public Object[]
toArray()

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).
public Object[]
toArray(Object[]
the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait