# named

@Incubating
open fun named(nameFilter: Spec<String>): NamedDomainObjectCollection<T>

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.

#### Return

The collection of objects with names satisfying the filter. Returns an empty collection if there are no such objects in this collection.

#### Since

8.6

#### Parameters

nameFilter

The specification to test names against.

abstract fun named(name: String): NamedDomainObjectProvider<T>

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

This method is lazy and will not cause the returned element to be realized.

#### Return

A Provider that will return the object when queried. The object may be created and configured at this point, if not already.

#### Since

4.10

#### Parameters

name

The object's name

#### Throws

UnknownDomainObjectException

If a object with the given name is not defined.

abstract fun named(name: String, configurationAction: Action<in T>): NamedDomainObjectProvider<T>

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

This method is lazy and will not cause the returned element to be realized.

#### Return

A Provider that will return the object when queried. The object may be created and configured at this point, if not already.

#### Since

5.0

#### Parameters

name

The object's name

#### Throws

UnknownDomainObjectException

If an object with the given name is not defined.

abstract fun <S : T?> named(name: String, type: Class<S>): NamedDomainObjectProvider<S>

Locates a object by name and type, failing if there is no such object.

This method is lazy and will not cause the returned element to be realized.

#### Return

A Provider that will return the object when queried. The object may be created and configured at this point, if not already.

#### Since

5.0

#### Parameters

name

The object's name

type

The object's type

#### Throws

UnknownDomainObjectException

If an object with the given name is not defined.

abstract fun <S : T?> named(name: String, type: Class<S>, configurationAction: Action<in S>): NamedDomainObjectProvider<S>

Locates a object by name and type, failing if there is no such object. The given configure action is executed against the object before it is returned from the provider.

This method is lazy and will not cause the returned element to be realized.

#### Return

A Provider that will return the object when queried. The object may be created and configured at this point, if not already.

#### Since

5.0

#### Parameters

name

The object's name

type

The object's type

configurationAction

The action to use to configure the object.

#### Throws

UnknownDomainObjectException

If an object with the given name is not defined.