api / org.gradle.model / ModelMap

ModelMap

@Incubating interface ModelMap<T : Any> : MutableIterable<T>, ModelElement

Model backed map like structure allowing adding of items where instantiation is managed.

org.gradle.model.Managed types may declare model map properties. Model maps can only contain managed types.

Parameters

- the contract type for all items

Functions

afterEach

abstract fun afterEach(configAction: Action<in T>): Unit

Applies the given action to each item in the collection, as each item is required.

The given action is invoked to configure the item when the item is required. It is called after any actions provided to #beforeEach(org.gradle.api.Action), #create(String, * org.gradle.api.Action), and other mutation methods.

abstract fun <S : Any> afterEach(type: Class<S>, configAction: Action<in S>): Unit

Applies the given action to each item of the given type in the collection, as each item is required.

The given action is invoked to configure the item when the item is required. It is called after any actions provided to #beforeEach(org.gradle.api.Action), #create(String, * org.gradle.api.Action), and other mutation methods.

all

abstract fun all(configAction: Action<in T>): Unit

Applies the given action to each item in the collection, as each item is required.

The given action is invoked to configure the item when the item is required. It is called after any actions provided to #beforeEach(org.gradle.api.Action) and #create(String, * org.gradle.api.Action).

beforeEach

abstract fun beforeEach(configAction: Action<in T>): Unit

Applies the given action to each item in this collection, as each item is required.

The given action is invoked to configure the item when the item is required. It is called before any actions provided to #create(String, org.gradle.api.Action).

abstract fun <S : Any> beforeEach(type: Class<S>, configAction: Action<in S>): Unit

Applies the given action to each item of the given type in this collection, as each item is required.

The given action is invoked to configure the item when the item is required. It is called before any actions provided to #create(String, org.gradle.api.Action).

containsKey

abstract fun containsKey(name: Any): Boolean

Returns true if this collection contains an item with the given name.

containsValue

abstract fun containsValue(item: Any): Boolean

Returns true if this collection contains the given item.

create

abstract fun create(name: String): Unit

Defines an item with the given name and type T. The item is not created immediately, but is instead created as it is required.

abstract fun create(name: String, configAction: Action<in T>): Unit

Defines an item with the given name and type T. The item is not created immediately, but is instead created as it is required.

The given action is invoked to configure the item when the item is required.

abstract fun <S : T> create(name: String, type: Class<S>): Unit

Defines an item with the given name and type. The item is not created immediately, but is instead created as it is required.

abstract fun <S : T> create(name: String, type: Class<S>, configAction: Action<in S>): Unit

Defines an item with the given name and type. The item is not created immediately, but is instead created as it is required.

The given action is invoked to configure the item when the item is required.

get

abstract fun get(name: Any): T
abstract fun get(name: String): T

Returns the item with the given name, if any.

isEmpty

abstract fun isEmpty(): Boolean

Returns true if this collection contains no items.

keySet

abstract fun keySet(): MutableSet<String>

Returns the names of the items in this collection.

named

abstract fun named(name: String, configAction: Action<in T>): Unit

Applies the given action to the given item, when the item is required.

The given action is invoked to configure the item when the item is required. It is called after any actions provided to #beforeEach(org.gradle.api.Action) and #create(String, * org.gradle.api.Action).

abstract fun named(name: String, ruleSource: Class<out RuleSource>): Unit

Applies the given rule source class to the given item, when the item is required.

Rules are applied in the scope of the item therefore:

  • subject by-type and by-path bindings are of inner scope
  • subject can be bound by type to a child of the scope in which the rule is applied
  • input by-path bindings are of inner scope
  • input by-type bindings are of outer scope

put

abstract fun put(name: String, instance: T): Unit

Adds an element to this ModelMap.

size

abstract fun size(): Int

Returns the number of items in this collection.

values

abstract fun values(): MutableCollection<T>

Returns the items in this collection.

withType

abstract fun <S : Any> withType(type: Class<S>): ModelMap<S>

Returns a collection containing the items from this collection which are of the specified type.

abstract fun <S : Any> withType(type: Class<S>, configAction: Action<in S>): Unit

Applies the given action to each item of the given type in the collection, as each item is required.

The given action is invoked to configure the item when the item is required. It is called after any actions provided to #beforeEach(org.gradle.api.Action) and #create(String, * org.gradle.api.Action).

abstract fun <S : Any> withType(type: Class<S>, rules: Class<out RuleSource>): Unit

Applies the given rules to all items of the collection of the given type.

Inherited Functions

getDisplayName

abstract fun getDisplayName(): String

Returns a human-consumable display name for this element.

getName

abstract fun getName(): String

Returns the name of this element. Each element has a name associated with it, that uniquely identifies the element amongst its siblings. Some element have their name generated or automatically assigned, and for these elements the name may not be human consumable.

Inheritors

BinaryContainer

interface BinaryContainer : ModelMap<BinarySpec>

A container for project binaries, which represent physical artifacts that can run on a particular platform or runtime.

ComponentSpecContainer

interface ComponentSpecContainer : ModelMap<ComponentSpec>

A container of software components.

FunctionalSourceSet

interface FunctionalSourceSet : ModelMap<LanguageSourceSet>

A container holding LanguageSourceSets with a similar function (production code, test code, etc.).

TestSuiteContainer

interface TestSuiteContainer : ModelMap<TestSuiteSpec>

A container of TestSuiteSpec instances.