Interface DomainObjectCollection<T>
- Type Parameters:
T- The type of domain objects in this collection.
- All Superinterfaces:
Collection<T>, Iterable<T>
- All Known Subinterfaces:
ArtifactRepositoryContainer, ArtifactTypeContainer, AuthenticationContainer, BinaryTasksCollection, BuildDashboardReports, BuildTypeContainer, CheckstyleReports, CodeNarcReports, ConfigurationContainer, DependencyConstraintSet, DependencyReportContainer, DependencySet, DistributionContainer, DomainObjectSet<T>, ExtensiblePolymorphicDomainObjectContainer<T>, FindBugsReports, FlavorContainer, IvyArtifactSet, IvyConfigurationContainer, JacocoReportsContainer, JarBinarySpec.TasksCollection, JDependReports, JvmTestSuiteBinarySpec.JvmTestSuiteTasks, MavenArtifactSet, NamedDomainObjectCollection<T>, NamedDomainObjectContainer<T>, NamedDomainObjectList<T>, NamedDomainObjectSet<T>, NativeExecutableBinarySpec.TasksCollection, NativeTestSuiteBinarySpec.TasksCollection, NativeToolChainRegistry, PlatformContainer, PlayDistributionContainer, PluginCollection<T>, PluginContainer, PmdReports, PolymorphicDomainObjectContainer<T>, PrebuiltLibraries, ProjectSourceSet, PublicationContainer, PublishArtifactSet, ReportContainer<T>, Repositories, RepositoryHandler, SharedLibraryBinarySpec.TasksCollection, SoftwareComponentContainer, SourceSetContainer, StaticLibraryBinarySpec.TasksCollection, TaskCollection<T>, TaskContainer, TestSuiteTaskCollection, TestTaskReports
A DomainObjectCollection is a specialised Collection that adds the ability to receive modification notifications and use live filtered sub collections.
The filtered collections returned by the filtering methods, such as matching(Closure), return collections that are live. That is, they reflect
changes made to the source collection that they were created from. This is true for filtered collections made from filtered collections etc.
You can also add actions which are executed as elements are added to the collection. Actions added to filtered collections will be fired if an addition/removal occurs for the source collection that matches the filter.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an element to this collection, given aProviderthat will provide the element when required.voidExecutes the given closure against all objects in this collection, and any objects subsequently added to this collection.voidExecutes the given action against all objects in this collection, and any objects subsequently added to this collection.<S extends T>
voidconfigureEachLater(Class<S> type, Action<? super S> action) Configures each element in this collection of the given type using the given action, as each element is required.voidconfigureEachLater(Action<? super T> action) Configures each element in this collection using the given action, as each element is required.Returns a collection which contains the objects in this collection which meet the given closure specification.Returns a collection which contains the objects in this collection which meet the given closure specification.Returns a collection which contains the objects in this collection which meet the given specification.voidwhenObjectAdded(Closure action) Adds a closure to be called when an object is added to this collection.whenObjectAdded(Action<? super T> action) Adds anActionto be executed when an object is added to this collection.voidwhenObjectRemoved(Closure action) Adds a closure to be called when an object is removed from this collection.whenObjectRemoved(Action<? super T> action) Adds anActionto be executed when an object is removed from this collection.<S extends T>
DomainObjectCollection<S> Returns a collection containing the objects in this collection of the given type.<S extends T>
DomainObjectCollection<S> Returns a collection containing the objects in this collection of the given type.<S extends T>
DomainObjectCollection<S> Returns a collection containing the objects in this collection of the given type.
-
Method Details
-
addLater
-
withType
Returns a collection containing the objects in this collection of the given type. The returned collection is live, so that when matching objects are later added to this collection, they are also visible in the filtered collection.- Parameters:
type- The type of objects to find.- Returns:
- The matching objects. Returns an empty collection if there are no such objects in this collection.
-
withType
Returns a collection containing the objects in this collection of the given type. Equivalent to callingwithType(type).all(configureAction)- Parameters:
type- The type of objects to find.configureAction- The action to execute for each object in the resulting collection.- Returns:
- The matching objects. Returns an empty collection if there are no such objects in this collection.
-
withType
Returns a collection containing the objects in this collection of the given type. Equivalent to callingwithType(type).all(configureClosure).- Parameters:
type- The type of objects to find.configureClosure- The closure to execute for each object in the resulting collection.- Returns:
- The matching objects. Returns an empty collection if there are no such objects in this collection.
-
matching
Returns a collection which contains the objects in this collection which meet the given specification. The returned collection is live, so that when matching objects are added to this collection, they are also visible in the filtered collection.- Parameters:
spec- The specification to use.- Returns:
- The collection of matching objects. Returns an empty collection if there are no such objects in this collection.
-
matching
Returns a collection which contains the objects in this collection which meet the given closure specification. The returned collection is live, so that when matching objects are added to this collection, they are also visible in the filtered collection.- Parameters:
spec- The specification to use. The closure gets a collection element as an argument.- Returns:
- The collection of matching objects. Returns an empty collection if there are no such objects in this collection.
-
whenObjectAdded
-
whenObjectAdded
Adds a closure to be called when an object is added to this collection. The newly added object is passed to the closure as the parameter.- Parameters:
action- The closure to be called
-
whenObjectRemoved
-
whenObjectRemoved
Adds a closure to be called when an object is removed from this collection. The removed object is passed to the closure as the parameter.- Parameters:
action- The closure to be called
-
all
-
all
Executes the given closure against all objects in this collection, and any objects subsequently added to this collection. The object is passed to the closure as the closure delegate. Alternatively, it is also passed as a parameter.- Parameters:
action- The action to be executed
-
configureEachLater
Configures each element in this collection using the given action, as each element is required. Actions are run in the order added. Note: this method currently has a placeholder name and will almost certainly be renamed.- Parameters:
action- AActionthat can configure the element when required.- Since:
- 4.8
-
configureEachLater
Configures each element in this collection of the given type using the given action, as each element is required. Actions are run in the order added. Note: this method currently has a placeholder name and will almost certainly be renamed.- Parameters:
type- The type of element.action- AActionthat can configure the element when required.- Since:
- 4.8
-
findAll
Returns a collection which contains the objects in this collection which meet the given closure specification.- Parameters:
spec- The specification to use. The closure gets a collection element as an argument.- Returns:
- The collection of matching objects. Returns an empty collection if there are no such objects in this collection.
-