Package groovy.util

# Class ObservableList

java.lang.Object
groovy.util.ObservableList

All Implemented Interfaces:
  `Iterable`, `Collection`, `List`

public class ObservableList extends Object implements List
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

- ObservableList.ElementAddedEvent - a new element is added to the list
- ObservableList.ElementRemovedEvent - an element is removed from the list
- ObservableList.ElementUpdatedEvent - an element changes value (same as regular PropertyChangeEvent)
- ObservableList.ElementClearedEvent - all elements have been removed from the list
- ObservableList.MultiElementAddedEvent - triggered by calling list.addAll()
- ObservableList.MultiElementRemovedEvent - triggered by calling list.removeAll()/list.retainAll()

Bound properties

- `content` - read-only.
- `size` - read-only.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `ObservableList.ChangeType`
  `static class`
  `ObservableList.ElementAddedEvent`
  `static class`
  `ObservableList.ElementClearedEvent`
  `static class`
  `ObservableList.ElementEvent`
  `static class`
  `ObservableList.ElementRemovedEvent`
  `static class`
  `ObservableList.ElementUpdatedEvent`
  `static class`
  `ObservableList.MultiElementAddedEvent`
  `static class`
  `ObservableList.MultiElementRemovedEvent`
  `protected class`
  `ObservableList.ObservableIterator`
  `protected class`
  `ObservableList.ObservableListIterator`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `CONTENT_PROPERTY`
  `static final String`
  `SIZE_PROPERTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ObservableList()`
  `ObservableList(Closure test)`
  `ObservableList(List delegate)`
  `ObservableList(List delegate, Closure test)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(int index, Object element)`
  `boolean`
  `add(Object o)`
  `boolean`
  `addAll(int index, Collection c)`
  `boolean`
  `addAll(Collection c)`
  `void`
  `addPropertyChangeListener(PropertyChangeListener listener)`
  `void`
  `addPropertyChangeListener(String propertyName, PropertyChangeListener listener)`
  `void`
  `clear()`
  `boolean`
  `contains(Object o)`
  `boolean`
  `containsAll(Collection c)`
  `boolean`
  `equals(Object o)`
  `protected void`
  `fireElementAddedEvent(int index, Object element)`
  `protected void`
  `fireElementClearedEvent(List values)`
  `protected void`
  `fireElementEvent(ObservableList.ElementEvent event)`
  `protected void`
  `fireElementRemovedEvent(int index, Object element)`
  `protected void`
  `fireElementUpdatedEvent(int index, Object oldValue, Object newValue)`
  `protected void`
  `fireMultiElementAddedEvent(int index, List values)`
  `protected void`
  `fireMultiElementRemovedEvent(List values)`
  `protected void`
  `fireSizeChangedEvent(int oldValue, int newValue)`
  `Object`
  `get(int index)`
  `List`
  `getContent()`
  `protected List`
  `getDelegateList()`
  `PropertyChangeListener[]`
  `getPropertyChangeListeners()`
  `PropertyChangeListener[]`
  `getPropertyChangeListeners(String propertyName)`
  `int`
  `getSize()`
  `protected Closure`
  `getTest()`
  `int`
  `hashCode()`
  `boolean`
  `hasListeners(String propertyName)`
  `int`
  `indexOf(Object o)`
  `boolean`
  `isEmpty()`
  `Iterator`
  `iterator()`
  `int`
  `lastIndexOf(Object o)`
  `ListIterator`
  `listIterator()`
  `ListIterator`
  `listIterator(int index)`
  `Object`
  `remove(int index)`
  `boolean`
  `remove(Object o)`
  `boolean`
  `removeAll(Collection c)`
  `void`
  `removePropertyChangeListener(PropertyChangeListener listener)`
  `void`
  `removePropertyChangeListener(String propertyName, PropertyChangeListener listener)`
  `boolean`
  `retainAll(Collection c)`
  `Object`
  `set(int index, Object element)`
  `int`
  `size()`
  `List`
  `subList(int fromIndex, int toIndex)`
  `Object[]`
  `toArray()`
  `Object[]`
  `toArray(Object[] a)`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.util.Collection

  `parallelStream, removeIf, stream, toArray`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

  ### Methods inherited from interface java.util.List

  `replaceAll, sort, spliterator`

- ## Field Details

  - ### SIZE_PROPERTY

    public static final String SIZE_PROPERTY
    See Also:
      - Constant Field Values

  - ### CONTENT_PROPERTY

    public static final String CONTENT_PROPERTY
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ObservableList

    public ObservableList()

  - ### ObservableList

    public ObservableList(List delegate)

  - ### ObservableList

    public ObservableList(Closure test)

  - ### ObservableList

    public ObservableList(List delegate, Closure test)

- ## Method Details

  - ### getContent

    public List getContent()

  - ### getDelegateList

    protected List getDelegateList()

  - ### getTest

    protected Closure getTest()

  - ### fireElementAddedEvent

    protected void fireElementAddedEvent(int index, Object element)

  - ### fireMultiElementAddedEvent

    protected void fireMultiElementAddedEvent(int index, List values)

  - ### fireElementClearedEvent

    protected void fireElementClearedEvent(List values)

  - ### fireElementRemovedEvent

    protected void fireElementRemovedEvent(int index, Object element)

  - ### fireMultiElementRemovedEvent

    protected void fireMultiElementRemovedEvent(List values)

  - ### fireElementUpdatedEvent

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

  - ### fireElementEvent

    protected void fireElementEvent(ObservableList.ElementEvent event)

  - ### fireSizeChangedEvent

    protected void fireSizeChangedEvent(int oldValue, int newValue)

  - ### add

    public void add(int index, Object element)
    Specified by:
      `add` in interface `List`

  - ### add

    public boolean add(Object o)
    Specified by:
      `add` in interface `Collection`
    Specified by:
      `add` in interface `List`

  - ### addAll

    public boolean addAll(Collection c)
    Specified by:
      `addAll` in interface `Collection`
    Specified by:
      `addAll` in interface `List`

  - ### addAll

    public boolean addAll(int index, Collection c)
    Specified by:
      `addAll` in interface `List`

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Collection`
    Specified by:
      `clear` in interface `List`

  - ### contains

    public boolean contains(Object o)
    Specified by:
      `contains` in interface `Collection`
    Specified by:
      `contains` in interface `List`

  - ### containsAll

    public boolean containsAll(Collection c)
    Specified by:
      `containsAll` in interface `Collection`
    Specified by:
      `containsAll` in interface `List`

  - ### equals

    public boolean equals(Object o)
    Specified by:
      `equals` in interface `Collection`
    Specified by:
      `equals` in interface `List`
    Overrides:
      `equals` in class `Object`

  - ### get

    public Object get(int index)
    Specified by:
      `get` in interface `List`

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in interface `Collection`
    Specified by:
      `hashCode` in interface `List`
    Overrides:
      `hashCode` in class `Object`

  - ### indexOf

    public int indexOf(Object o)
    Specified by:
      `indexOf` in interface `List`

  - ### isEmpty

    public boolean isEmpty()
    Specified by:
      `isEmpty` in interface `Collection`
    Specified by:
      `isEmpty` in interface `List`

  - ### iterator

    public Iterator iterator()
    Specified by:
      `iterator` in interface `Collection`
    Specified by:
      `iterator` in interface `Iterable`
    Specified by:
      `iterator` in interface `List`

  - ### lastIndexOf

    public int lastIndexOf(Object o)
    Specified by:
      `lastIndexOf` in interface `List`

  - ### listIterator

    public ListIterator listIterator()
    Specified by:
      `listIterator` in interface `List`

  - ### listIterator

    public ListIterator listIterator(int index)
    Specified by:
      `listIterator` in interface `List`

  - ### remove

    public Object remove(int index)
    Specified by:
      `remove` in interface `List`

  - ### remove

    public boolean remove(Object o)
    Specified by:
      `remove` in interface `Collection`
    Specified by:
      `remove` in interface `List`

  - ### removeAll

    public boolean removeAll(Collection c)
    Specified by:
      `removeAll` in interface `Collection`
    Specified by:
      `removeAll` in interface `List`

  - ### retainAll

    public boolean retainAll(Collection c)
    Specified by:
      `retainAll` in interface `Collection`
    Specified by:
      `retainAll` in interface `List`

  - ### set

    public Object set(int index, Object element)
    Specified by:
      `set` in interface `List`

  - ### size

    public int size()
    Specified by:
      `size` in interface `Collection`
    Specified by:
      `size` in interface `List`

  - ### getSize

    public int getSize()

  - ### subList

    public List subList(int fromIndex, int toIndex)
    Specified by:
      `subList` in interface `List`

  - ### toArray

    public Object[] toArray()
    Specified by:
      `toArray` in interface `Collection`
    Specified by:
      `toArray` in interface `List`

  - ### toArray

    public Object[] toArray(Object[] a)
    Specified by:
      `toArray` in interface `Collection`
    Specified by:
      `toArray` in interface `List`

  - ### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

  - ### addPropertyChangeListener

    public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)

  - ### getPropertyChangeListeners

    public PropertyChangeListener[] getPropertyChangeListeners()

  - ### getPropertyChangeListeners

    public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)

  - ### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

  - ### removePropertyChangeListener

    public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)

  - ### hasListeners

    public boolean hasListeners(String propertyName)