org.gradle.model

## Interface ModelMap<T>

- Type Parameters:
    `T` - the contract type for all items
  All Superinterfaces:
    CollectionBuilder<T>, Iterable<T>
  All Known Subinterfaces:
    ComponentSpecContainer, TestSuiteContainer

      @Incubating
      public interface ModelMap<T>
      extends CollectionBuilder<T>, Iterable<T>

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

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

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterEach(Action<? super T> configAction)` Applies the given action to each item in the collection, as each item is required.
    `<S> void` | `afterEach(Class<S> type, Action<? super S> configAction)` Applies the given action to each item of the given type in the collection, as each item is required.
    `void` | `all(Action<? super T> configAction)` Applies the given action to each item in the collection, as each item is required.
    `void` | `beforeEach(Action<? super T> configAction)` Applies the given action to each item in this collection, as each item is required.
    `<S> void` | `beforeEach(Class<S> type, Action<? super S> configAction)` Applies the given action to each item of the given type in this collection, as each item is required.
    `boolean` | `containsKey(Object name)` Returns true if this collection contains an item with the given name.
    `boolean` | `containsValue(Object item)` Returns true if this collection contains the given item.
    `void` | `create(String name)` Defines an item with the given name and type T.
    `void` | `create(String name, Action<? super T> configAction)` Defines an item with the given name and type T.
    `<S extends T> void` | `create(String name, Class<S> type)` Defines an item with the given name and type.
    `<S extends T> void` | `create(String name, Class<S> type, Action<? super S> configAction)` Defines an item with the given name and type.
    `T` | `get(Object name)` Returns the item with the given name, if any.
    `T` | `get(String name)` Returns the item with the given name, if any.
    `boolean` | `isEmpty()` Returns true if this collection contains no items.
    `Set<String>` | `keySet()` Returns the names of the items in this collection.
    `void` | `named(String name, Action<? super T> configAction)` Applies the given action to the given item, when the item is required.
    `void` | `named(String name, Class<? extends RuleSource> ruleSource)` Applies the given rule source class to the given item, when the item is required.
    `int` | `size()` Returns the number of items in this collection.
    `Collection<T>` | `values()` Returns the items in this collection.
    `<S> ModelMap<S>` | `withType(Class<S> type)` Returns a collection containing the items from this collection which are of the specified type.
    `<S> void` | `withType(Class<S> type, Action<? super S> configAction)` Applies the given action to each item of the given type in the collection, as each item is required.
    `<S> void` | `withType(Class<S> type, Class<? extends RuleSource> rules)` Applies the given rules to all items of the collection of the given type.

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

      `iterator`

- - ### Method Detail

    - #### withType

          <S> ModelMap<S> withType(Class<S> type)

      Returns a collection containing the items from this collection which are of the specified type.
      Specified by:
        `withType` in interface `CollectionBuilder<T>`
      Type Parameters:
        `S` - The type.
      Parameters:
        `type` - The type.
      Returns:
        The collection.

    - #### size

          int size()

      Returns the number of items in this collection.
      Specified by:
        `size` in interface `CollectionBuilder<T>`
      Returns:
        the size of this collection.

    - #### isEmpty

          boolean isEmpty()

      Returns true if this collection contains no items.
      Specified by:
        `isEmpty` in interface `CollectionBuilder<T>`
      Returns:
        true if this collection is empty.

    - #### get

          @Nullable
          T get(Object name)

      Returns the item with the given name, if any.
      Specified by:
        `get` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name of the item.
      Returns:
        The item, or null if no such item.

    - #### get

          @Nullable
          T get(String name)

      Returns the item with the given name, if any.
      Specified by:
        `get` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name of the item.
      Returns:
        The item, or null if no such item.

    - #### containsKey

          boolean containsKey(Object name)

      Returns true if this collection contains an item with the given name.
      Specified by:
        `containsKey` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name of the item.
      Returns:
        true if this collection contains an item with the given name.

    - #### containsValue

          boolean containsValue(Object item)

      Returns true if this collection contains the given item.
      Specified by:
        `containsValue` in interface `CollectionBuilder<T>`
      Parameters:
        `item` - The item.
      Returns:
        true if this collection contains the given item.

    - #### keySet

          Set<String> keySet()

      Returns the names of the items in this collection.
      Specified by:
        `keySet` in interface `CollectionBuilder<T>`
      Returns:
        The names

    - #### create

          void create(String name)

      Defines an item with the given name and type T. The item is not created immediately, but is instead created as it is required.
      Specified by:
        `create` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name.

    - #### create

          void create(String name,
                    Action<? super T> configAction)

      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.

      Specified by:
        `create` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name.
        `configAction` - An action that initialises the item. The action is executed when the item is required.

    - #### create

          <S extends T> void create(String name,
                                  Class<S> type)

      Defines an item with the given name and type. The item is not created immediately, but is instead created as it is required.
      Specified by:
        `create` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name.

    - #### create

          <S extends T> void create(String name,
                                  Class<S> type,
                                  Action<? super S> configAction)

      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.

      Specified by:
        `create` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name.
        `configAction` - An action that initialises the item. The action is executed when the item is required.

    - #### named

          void named(String name,
                   Action<? super T> configAction)

      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 `CollectionBuilder.beforeEach(org.gradle.api.Action)` and `CollectionBuilder.create(String, org.gradle.api.Action)`.

      Specified by:
        `named` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name.
        `configAction` - An action that configures the item. The action is executed when the item is required.

    - #### named

          void named(String name,
                   Class<? extends RuleSource> ruleSource)

      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
      Specified by:
        `named` in interface `CollectionBuilder<T>`
      Parameters:
        `name` - The name.
        `ruleSource` - A rule source class.

    - #### beforeEach

          void beforeEach(Action<? super T> configAction)

      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 `CollectionBuilder.create(String, org.gradle.api.Action)`.

      Specified by:
        `beforeEach` in interface `CollectionBuilder<T>`
      Parameters:
        `configAction` - An action that configures the item. The action is executed when the item is required.

    - #### beforeEach

          <S> void beforeEach(Class<S> type,
                            Action<? super S> configAction)

      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 `CollectionBuilder.create(String, org.gradle.api.Action)`.

      Specified by:
        `beforeEach` in interface `CollectionBuilder<T>`
      Parameters:
        `type` - The type of elements to apply the action to.
        `configAction` - An action that configures the item. The action is executed when the item is required.

    - #### all

          void all(Action<? super T> configAction)

      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 `CollectionBuilder.beforeEach(org.gradle.api.Action)` and `CollectionBuilder.create(String, org.gradle.api.Action)`.

      Specified by:
        `all` in interface `CollectionBuilder<T>`
      Parameters:
        `configAction` - An action that configures the item. The action is executed when the item is required.

    - #### withType

          <S> void withType(Class<S> type,
                          Action<? super S> configAction)

      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 `CollectionBuilder.beforeEach(org.gradle.api.Action)` and `CollectionBuilder.create(String, org.gradle.api.Action)`.

      Specified by:
        `withType` in interface `CollectionBuilder<T>`
      Parameters:
        `type` - The type of elements to apply the action to.
        `configAction` - An action that configures the item. The action is executed when the item is required.

    - #### withType

          <S> void withType(Class<S> type,
                          Class<? extends RuleSource> rules)

      Description copied from interface: `CollectionBuilder`
      Applies the given rules to all items of the collection of the given type.
      Specified by:
        `withType` in interface `CollectionBuilder<T>`
      Parameters:
        `type` - the type that the item must be/implement to have the rules applied
        `rules` - rules to apply

    - #### afterEach

          void afterEach(Action<? super T> configAction)

      Description copied from interface: `CollectionBuilder`
      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 `CollectionBuilder.beforeEach(org.gradle.api.Action)`, `CollectionBuilder.create(String, org.gradle.api.Action)`, and other mutation methods.

      Specified by:
        `afterEach` in interface `CollectionBuilder<T>`
      Parameters:
        `configAction` - An action that configures the item. The action is executed when the item is required.

    - #### afterEach

          <S> void afterEach(Class<S> type,
                           Action<? super S> configAction)

      Description copied from interface: `CollectionBuilder`
      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 `CollectionBuilder.beforeEach(org.gradle.api.Action)`, `CollectionBuilder.create(String, org.gradle.api.Action)`, and other mutation methods.

      Specified by:
        `afterEach` in interface `CollectionBuilder<T>`
      Parameters:
        `type` - The type of elements to apply the action to.
        `configAction` - An action that configures the item. The action is executed when the item is required.

    - #### values

          Collection<T> values()

      Returns the items in this collection.
      Specified by:
        `values` in interface `CollectionBuilder<T>`
      Returns:
        The items.