|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- The type of domain objects in this collection.public interface NamedDomainObjectCollection<T>
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
Method Summary | ||
---|---|---|
T |
findByName(String name)
Locates an object by name, returning null if there is no such object. |
|
Map<String,T> |
getAsMap()
Returns the objects in this collection, as a map from object name to object instance. |
|
T |
getAt(String name)
Locates an object by name, failing if there is no such task. |
|
T |
getByName(String name)
Locates an object by name, failing if there is no such object. |
|
T |
getByName(String name,
Closure configureClosure)
Locates an object by name, failing if there is no such object. |
|
NamedDomainObjectCollection<T> |
matching(Closure spec)
Returns a collection which contains the objects in this collection which meet the given closure specification. |
|
NamedDomainObjectCollection<T> |
matching(Spec<? super T> spec)
Returns a collection which contains the objects in this collection which meet the given specification. |
|
|
withType(Class<S> type)
Returns a collection containing the objects in this collection of the given type. |
Methods inherited from interface org.gradle.api.DomainObjectCollection |
---|
allObjects, allObjects, findAll, getAll, whenObjectAdded, whenObjectAdded, whenObjectRemoved |
Methods inherited from interface java.lang.Iterable |
---|
iterator |
Method Detail |
---|
Map<String,T> getAsMap()
T findByName(String name)
name
- The object name
T getByName(String name) throws UnknownDomainObjectException
name
- The object name
UnknownDomainObjectException
- when there is no such object in this collection.T getByName(String name, Closure configureClosure) throws UnknownDomainObjectException
name
- The object nameconfigureClosure
- The closure to use to configure the object.
UnknownDomainObjectException
- when there is no such object in this collection.T getAt(String name) throws UnknownDomainObjectException
getByName(String)
. You can call this method in your build script by using the groovy []
operator.
name
- The object name
UnknownDomainObjectException
- when there is no such object in this collection.<S extends T> NamedDomainObjectCollection<S> withType(Class<S> type)
withType
in interface DomainObjectCollection<T>
type
- The type of objects to find.
NamedDomainObjectCollection<T> matching(Spec<? super T> spec)
matching
in interface DomainObjectCollection<T>
spec
- The specification to use.
NamedDomainObjectCollection<T> matching(Closure spec)
matching
in interface DomainObjectCollection<T>
spec
- The specification to use. The closure gets a collection element as an argument.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |