Package org.gradle.api

# Interface NamedDomainObjectSet<T>

Type Parameters:
  `T` - The type of objects in the set

All Superinterfaces:
  `Collection<T>`, `DomainObjectCollection<T>`, `DomainObjectSet<T>`, `Iterable<T>`, `NamedDomainObjectCollection<T>`, `Set<T>`

All Known Subinterfaces:
  `ArtifactTransformReports`, `ArtifactTypeContainer`, `AuthenticationContainer`, `BuildDashboardReports`, `BuildTypeContainer`, `CheckstyleReports`, `CodeNarcReports`, `ConfigurationContainer`, `ConfigurationReports`, `DependencyReportContainer`, `DistributionContainer`, `ExtensiblePolymorphicDomainObjectContainer<T>`, `FlavorContainer`, `IvyConfigurationContainer`, `JacocoReportsContainer`, `MutableVersionCatalogContainer`, `NamedDomainObjectContainer<T>`, `NativeToolChainRegistry`, `PlatformContainer`, `PmdReports`, `PolymorphicDomainObjectContainer<T>`, `PrebuiltLibraries`, `PublicationContainer`, `ReportContainer<T>`, `Repositories`, `SoftwareComponentContainer`, `SourceSetContainer`, `TaskCollection<T>`, `TaskContainer`, `TestTaskReports`

@ManagedType public interface NamedDomainObjectSet<T> extends NamedDomainObjectCollection<T>, DomainObjectSet<T>

A specialization 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.

See Also:
  - `Create an instance of this as a managed property (preferred).`
  - `Create an instance of this manually.`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Set<T>`
  `findAll(Closure spec)`
  Returns a collection which contains the objects in this collection which meet the given closure specification.
  `NamedDomainObjectSet<T>`
  `matching(Closure spec)`
  Returns a collection which contains the objects in this collection which meet the given closure specification.
  `NamedDomainObjectSet<T>`
  `matching(Spec<? super T> spec)`
  Returns a collection which contains the objects in this collection which meet the given specification.
  `NamedDomainObjectSet<T>`
  `named(Spec<String> nameFilter)`
  Returns a collection containing the objects with names matching the provided filter.
  `<S extends T>
  NamedDomainObjectSet<S>`
  `withType(Class<S> type)`
  Returns a collection containing the objects in this collection of the given type.

  ### Methods inherited from interface java.util.Collection

  `parallelStream, removeIf, stream, toArray`

  ### Methods inherited from interface org.gradle.api.DomainObjectCollection

  `addAllLater, addLater, all, all, configureEach, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

  ### Methods inherited from interface org.gradle.api.NamedDomainObjectCollection

  `add, addAll, addRule, addRule, addRule, findByName, getAsMap, getAt, getByName, getByName, getByName, getCollectionSchema, getNamer, getNames, getRules, named, named, named, named`

  ### Methods inherited from interface java.util.Set

  `add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray`

- ## Method Details

  - ### withType

    <S extends T> NamedDomainObjectSet<S> withType(Class<S> type)
    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.

    This method is an intermediate operation. It does not change the realized/unrealized state of the elements in the collection.

    Specified by:
      `withType` in interface `DomainObjectCollection<T>`
    Specified by:
      `withType` in interface `DomainObjectSet<T>`
    Specified by:
      `withType` in interface `NamedDomainObjectCollection<T>`
    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.

  - ### named

    NamedDomainObjectSet<T> named(Spec<String> nameFilter)
    Returns a collection containing the objects with names matching the provided filter. The returned collection is live, so that when matching objects are added to this collection, they are also visible in the filtered collection.

    This method is an intermediate operation. It does not change the realized/unrealized state of the elements in the collection.

    Specified by:
      `named` in interface `NamedDomainObjectCollection<T>`
    Parameters:
      `nameFilter` - The specification to test names against.
    Returns:
      The collection of objects with names satisfying the filter. Returns an empty collection if there are no such objects in this collection.

  - ### matching

    NamedDomainObjectSet<T> matching(Spec<? super T> spec)
    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.

    This method is an intermediate eager operation. The application of the filter forces the realization of the collection elements.

    Specified by:
      `matching` in interface `DomainObjectCollection<T>`
    Specified by:
      `matching` in interface `DomainObjectSet<T>`
    Specified by:
      `matching` in interface `NamedDomainObjectCollection<T>`
    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

    NamedDomainObjectSet<T> matching(Closure spec)
    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.

    This method is an intermediate eager operation. The application of the filter forces the realization of the collection elements.

    Specified by:
      `matching` in interface `DomainObjectCollection<T>`
    Specified by:
      `matching` in interface `DomainObjectSet<T>`
    Specified by:
      `matching` in interface `NamedDomainObjectCollection<T>`
    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.

  - ### findAll

    Set<T> findAll(Closure spec)
    Returns a collection which contains the objects in this collection which meet the given closure specification.

    This method is an eager operation. The application of the filter forces the realization of all of the underlying collection elements.

    Specified by:
      `findAll` in interface `DomainObjectCollection<T>`
    Specified by:
      `findAll` in interface `DomainObjectSet<T>`
    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.