|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
interface DomainObjectCollection extends java.lang.Iterable
A DomainObjectCollection represents a read-only set of domain objects of type T.
The object in a collection are accessable as read-only properties of the collection, using the name of the object as the property name. For example:
tasks.add('myTask') tasks.myTask.dependsOn someOtherTask
A dynamic method is added for each object which takes a configuration closure. This is equivalent to calling #getByName(String, groovy.lang.Closure). For example:
tasks.add('myTask') tasks.myTask { dependsOn someOtherTask }
You can also use the [] operator to access the objects of a collection by name. For example:
tasks.add('myTask') tasks['myTask'].dependsOn someOtherTask
Method Summary | |
---|---|
void
|
allObjects(Action action)
Executes the given action against all objects in this collection, and any objects subsequently added to this collection. |
void
|
allObjects(Closure action)
Executes the given closure against all objects in this collection, and any objects subsequently added to this collection. |
Set
|
findAll(Spec spec)
Returns the objects in this collection which meet the given specification. |
T
|
findByName(java.lang.String name)
Locates an object by name, returning null if there is no such object. |
Set
|
getAll()
Returns the objects in this collection. |
Map
|
getAsMap()
Returns the objects in this collection, as a map from object name to object instance. |
T
|
getAt(java.lang.String name)
Locates an object by name, failing if there is no such task. |
T
|
getByName(java.lang.String name)
Locates an object by name, failing if there is no such object. |
T
|
getByName(java.lang.String name, Closure configureClosure)
Locates an object by name, failing if there is no such object. |
DomainObjectCollection
|
matching(Spec spec)
Returns a collection which contains the objects in this collection which meet the given specification. |
Action
|
whenObjectAdded(Action action)
Adds an { |
void
|
whenObjectAdded(Closure action)
Adds a closure to be called when an object is added to this collection. |
Action
|
whenObjectRemoved(Action action)
Adds an { |
DomainObjectCollection
|
withType(java.lang.Class type)
Returns a collection containing the objects in this collection of the given type. |
Methods inherited from interface java.lang.Iterable | |
---|---|
iterator |
Methods inherited from class java.lang.Object | |
---|---|
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll |
Method Detail |
---|
public void allObjects(Action action)
public void allObjects(Closure action)
public Set findAll(Spec spec)
public T findByName(java.lang.String name)
public Set getAll()
public Map getAsMap()
public T getAt(java.lang.String name)
public T getByName(java.lang.String name)
public T getByName(java.lang.String name, Closure configureClosure)
public DomainObjectCollection matching(Spec spec)
public Action whenObjectAdded(Action action)
public void whenObjectAdded(Closure action)
public Action whenObjectRemoved(Action action)
public DomainObjectCollection withType(java.lang.Class type)
Groovy Documentation