api / org.gradle.api / NamedDomainObjectSet

NamedDomainObjectSet

interface NamedDomainObjectSet<T : Any> : NamedDomainObjectCollection<T>, MutableSet<T>

A specialisation of NamedDomainObjectCollection that also implements Set and orders objects by their inherent name.

All object equality is determined in terms of object names. That is, calling remove() with an object that is NOT equal to an existing object in terms of equals, but IS in terms of name equality will result in the existing collection item with the equal name being removed.

Parameters

- The type of element in the set

Functions

findAll

abstract fun findAll(spec: Closure<Any>): MutableSet<T>

{@inheritDoc}

matching

abstract fun matching(spec: Spec<in T>): NamedDomainObjectSet<T>
abstract fun matching(spec: Closure<Any>): NamedDomainObjectSet<T>

{@inheritDoc}

withType

abstract fun <S : T> withType(type: Class<S>): NamedDomainObjectSet<S>

{@inheritDoc}

Inherited Functions

add

abstract fun add(element: T): Boolean

Adds an object to the collection, if there is no existing object in the collection with the same name.

addAll

abstract fun addAll(elements: Collection<T>): Boolean

Adds any of the given objects to the collection that do not have the same name as any existing element.

addRule

abstract fun addRule(rule: Rule): Rule

Adds a rule to this collection. The given rule is invoked when an unknown object is requested by name.

abstract fun addRule(description: String, ruleAction: Closure<Any>): Rule

Adds a rule to this collection. The given closure is executed when an unknown object is requested by name. The requested name is passed to the closure as a parameter.

abstract fun addRule(description: String, ruleAction: Action<String>): Rule

Adds a rule to this collection. The given action is executed when an unknown object is requested by name. The requested name is passed to the action.

findByName

abstract fun findByName(name: String): T

Locates an object by name, returning null if there is no such object.

getAsMap

abstract fun getAsMap(): SortedMap<String, T>

Returns the objects in this collection, as a map from object name to object instance.

The map is ordered by the natural ordering of the object names (i.e. keys).

getAt

abstract fun getAt(name: String): T

Locates an object by name, failing if there is no such task. This method is identical to . You can call this method in your build script by using the groovy [] operator.

getByName

abstract fun getByName(name: String): T

Locates an object by name, failing if there is no such object.

abstract fun getByName(name: String, configureClosure: Closure<Any>): T

Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.

abstract fun getByName(name: String, configureAction: Action<in T>): T

Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.

getNamer

abstract fun getNamer(): Namer<T>

An object that represents the naming strategy used to name objects of this collection.

getNames

abstract fun getNames(): SortedSet<String>

Returns the names of the objects in this collection as a Set of Strings.

The set of names is in natural ordering.

getRules

abstract fun getRules(): MutableList<Rule>

Returns the rules used by this collection.

Inheritors

NamedDomainObjectContainer

interface NamedDomainObjectContainer<T : Any> : NamedDomainObjectSet<T>, Configurable

A named domain object container is a specialisation of NamedDomainObjectSet that adds the ability to create instances of the element type.

Implementations may use different strategies for creating new object instances.

Note that a container is an implementation of java.util.SortedSet, which means that the container is guaranteed to only contain elements with unique names within this container. Furthermore, items are ordered by their name.

PrebuiltLibraries

interface PrebuiltLibraries : ArtifactRepository, NamedDomainObjectSet<PrebuiltLibrary>

A container of PrebuiltLibrary instances.

ReportContainer

interface ReportContainer<T : Report> : NamedDomainObjectSet<T>, Configurable

A container of Report objects, that represent potential reports.

Things that produce reports (typically tasks) expose a report container that contains Report objects for each possible report that they can produce. Each report object can be configured individually, including whether or not it should be produced by way of its enabled property.

ReportContainer implementations are immutable in that standard collection methods such as add(), remove() and clear() will throw an ImmutableViolationException. However, implementations may provide new methods that allow the addition of new report object and/or the removal of existing report objects.

SoftwareComponentContainer

interface SoftwareComponentContainer : NamedDomainObjectSet<SoftwareComponent>

A Container that contains all of the Software Components produced by a Project.

SourceSetContainer

interface SourceSetContainer : NamedDomainObjectContainer<SourceSet>, NamedDomainObjectSet<SourceSet>

A SourceSetContainer manages a set of SourceSet objects.

TaskCollection

interface TaskCollection<T : Task> : NamedDomainObjectSet<T>

A TaskCollection contains a set of Task instances, and provides a number of query methods.