|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
org.gradle.api.DomainObjectCollectionorg.gradle.api.NamedDomainObjectCollection
public interface NamedDomainObjectCollection extends DomainObjectCollection
A NamedDomainObjectCollection represents a read-only set of domain objects of type T. Each domain object in this collection has a name, which uniquely identifies the object in this collection.
Each object in a collection are accessible 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
- The type of domain objects in this collection.Method Summary | |
---|---|
T
|
findByName(java.lang.String name)
Locates an object by name, returning null if there is no such object. |
java.util.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, groovy.lang.Closure configureClosure)
Locates an object by name, failing if there is no such object. |
NamedDomainObjectCollection
|
matching(Spec spec)
{@inheritDoc} |
NamedDomainObjectCollection
|
matching(groovy.lang.Closure spec)
{@inheritDoc} |
NamedDomainObjectCollection
|
withType(java.lang.Class type)
{@inheritDoc} |
Methods inherited from interface DomainObjectCollection | |
---|---|
allObjects, allObjects, findAll, getAll, matching, matching, whenObjectAdded, whenObjectAdded, whenObjectRemoved, withType |
Methods inherited from interface java.lang.Iterable | |
---|---|
java.lang.Iterable#iterator() |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Method Detail |
---|
public T findByName(java.lang.String name)
name
- The object name
public java.util.Map getAsMap()
public T getAt(java.lang.String name)
name
- The object name
public T getByName(java.lang.String name)
name
- The object name
public T getByName(java.lang.String name, groovy.lang.Closure configureClosure)
name
- The object nameconfigureClosure
- The closure to use to configure the object.
public NamedDomainObjectCollection matching(Spec spec)
public NamedDomainObjectCollection matching(groovy.lang.Closure spec)
public NamedDomainObjectCollection withType(java.lang.Class type)
Groovy Documentation