Package groovy.util
Class ObservableList
java.lang.Object
groovy.util.ObservableList
- All Implemented Interfaces:
- Iterable,- Collection,- 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:
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 SummaryNested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic classstatic classstatic classstatic classstatic classstatic classprotected classprotected class
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionObservableList(Closure test) ObservableList(List delegate) ObservableList(List delegate, Closure test) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection c) booleanaddAll(Collection c) voidvoidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) voidclear()booleanbooleanbooleanprotected voidfireElementAddedEvent(int index, Object element) protected voidfireElementClearedEvent(List values) protected voidprotected voidfireElementRemovedEvent(int index, Object element) protected voidfireElementUpdatedEvent(int index, Object oldValue, Object newValue) protected voidfireMultiElementAddedEvent(int index, List values) protected voidfireMultiElementRemovedEvent(List values) protected voidfireSizeChangedEvent(int oldValue, int newValue) get(int index) protected ListgetPropertyChangeListeners(String propertyName) intgetSize()protected ClosuregetTest()inthashCode()booleanhasListeners(String propertyName) intbooleanisEmpty()iterator()intlistIterator(int index) remove(int index) booleanbooleanvoidvoidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) booleanintsize()subList(int fromIndex, int toIndex) Object[]toArray()Object[]Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.ListreplaceAll, sort, spliterator
- 
Field Details- 
SIZE_PROPERTY- See Also:
 
- 
CONTENT_PROPERTY- See Also:
 
 
- 
- 
Constructor Details- 
ObservableListpublic ObservableList()
- 
ObservableList
- 
ObservableList
- 
ObservableList
 
- 
- 
Method Details- 
getContent
- 
getDelegateList
- 
getTest
- 
fireElementAddedEvent
- 
fireMultiElementAddedEvent
- 
fireElementClearedEvent
- 
fireElementRemovedEvent
- 
fireMultiElementRemovedEvent
- 
fireElementUpdatedEvent
- 
fireElementEvent
- 
fireSizeChangedEventprotected void fireSizeChangedEvent(int oldValue, int newValue) 
- 
add
- 
add- Specified by:
- addin interface- Collection
- Specified by:
- addin interface- List
 
- 
addAll- Specified by:
- addAllin interface- Collection
- Specified by:
- addAllin interface- List
 
- 
addAll
- 
clearpublic void clear()- Specified by:
- clearin interface- Collection
- Specified by:
- clearin interface- List
 
- 
contains- Specified by:
- containsin interface- Collection
- Specified by:
- containsin interface- List
 
- 
containsAll- Specified by:
- containsAllin interface- Collection
- Specified by:
- containsAllin interface- List
 
- 
equals
- 
get
- 
hashCodepublic int hashCode()
- 
indexOf
- 
isEmptypublic boolean isEmpty()- Specified by:
- isEmptyin interface- Collection
- Specified by:
- isEmptyin interface- List
 
- 
iterator
- 
lastIndexOf- Specified by:
- lastIndexOfin interface- List
 
- 
listIterator- Specified by:
- listIteratorin interface- List
 
- 
listIterator- Specified by:
- listIteratorin interface- List
 
- 
remove
- 
remove- Specified by:
- removein interface- Collection
- Specified by:
- removein interface- List
 
- 
removeAll- Specified by:
- removeAllin interface- Collection
- Specified by:
- removeAllin interface- List
 
- 
retainAll- Specified by:
- retainAllin interface- Collection
- Specified by:
- retainAllin interface- List
 
- 
set
- 
sizepublic int size()- Specified by:
- sizein interface- Collection
- Specified by:
- sizein interface- List
 
- 
getSizepublic int getSize()
- 
subList
- 
toArray- Specified by:
- toArrayin interface- Collection
- Specified by:
- toArrayin interface- List
 
- 
toArray- Specified by:
- toArrayin interface- Collection
- Specified by:
- toArrayin interface- List
 
- 
addPropertyChangeListener
- 
addPropertyChangeListener
- 
getPropertyChangeListeners
- 
getPropertyChangeListeners
- 
removePropertyChangeListener
- 
removePropertyChangeListener
- 
hasListeners
 
-