# Interface ModelMap<T>

Type Parameters:
  `T` - the contract type for all items

All Superinterfaces:
  `Iterable<T>, ModelElement, Named`

All Known Subinterfaces:
  `BinaryContainer, ComponentSpecContainer, FunctionalSourceSet, TestSuiteContainer`

@Incubating @Deprecated public interface ModelMap<T> extends Iterable<T>, ModelElement
Deprecated.
The Gradle software model is deprecated and will be removed in Gradle 10. Use the new component model (e.g. `cpp-application`, `cpp-library`, `swift-application`, `swift-library`, `xctest`) instead.
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.

Since:
  2.5

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Named

  `Named.Namer`

- ## Method Summary

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

  ### Methods inherited from interface Iterable

  `forEach, iterator, spliterator`

  ### Methods inherited from interface ModelElement

  `getDisplayName, getName`

- ## Method Details

  - ### withType

    <S> ModelMap<S> withType(Class<S> type)
    Deprecated.
    Returns a collection containing the items from this collection which are of the specified type.
    Type Parameters:
      `S` - The type.
    Parameters:
      `type` - The type.
    Returns:
      The collection.
    Since:
      2.5

  - ### size

    int size()
    Deprecated.
    Returns the number of items in this collection.
    Returns:
      the size of this collection.
    Since:
      2.5

  - ### isEmpty

    boolean isEmpty()
    Deprecated.
    Returns true if this collection contains no items.
    Returns:
      true if this collection is empty.
    Since:
      2.5

  - ### get

    @Nullable T get(Object name)
    Deprecated.
    Returns the item with the given name, if any.
    Parameters:
      `name` - The name of the item.
    Returns:
      The item, or null if no such item.
    Since:
      2.5

  - ### get

    @Nullable T get(String name)
    Deprecated.
    Returns the item with the given name, if any.
    Parameters:
      `name` - The name of the item.
    Returns:
      The item, or null if no such item.
    Since:
      2.5

  - ### containsKey

    boolean containsKey(Object name)
    Deprecated.
    Returns true if this collection contains an item with the given name.
    Parameters:
      `name` - The name of the item.
    Returns:
      true if this collection contains an item with the given name.
    Since:
      2.5

  - ### containsValue

    boolean containsValue(Object item)
    Deprecated.
    Returns true if this collection contains the given item.
    Parameters:
      `item` - The item.
    Returns:
      true if this collection contains the given item.
    Since:
      2.5

  - ### keySet

    Set<String> keySet()
    Deprecated.
    Returns the names of the items in this collection.
    Returns:
      The names
    Since:
      2.5

  - ### create

    void create(String name)
    Deprecated.
    Defines an item with the given name and type T. The item is not created immediately, but is instead created as it is required.
    Parameters:
      `name` - The name.
    Since:
      2.5

  - ### create

    void create(String name, Action<? super T> configAction)
    Deprecated.
    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.

    Parameters:
      `name` - The name.
      `configAction` - An action that initialises the item. The action is executed when the item is required.
    Since:
      2.5

  - ### create

    <S extends T> void create(String name, Class<S> type)
    Deprecated.
    Defines an item with the given name and type. The item is not created immediately, but is instead created as it is required.
    Parameters:
      `name` - The name.
    Since:
      2.5

  - ### create

    <S extends T> void create(String name, Class<S> type, Action<? super S> configAction)
    Deprecated.
    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.

    Parameters:
      `name` - The name.
      `configAction` - An action that initialises the item. The action is executed when the item is required.
    Since:
      2.5

  - ### put

    void put(String name, T instance)
    Deprecated.
    Adds an element to this `ModelMap`.
    Since:
      2.9

  - ### named

    void named(String name, Action<? super T> configAction)
    Deprecated.
    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)`.

    Parameters:
      `name` - The name.
      `configAction` - An action that configures the item. The action is executed when the item is required.
    Since:
      2.5

  - ### named

    void named(String name, Class<? extends RuleSource> ruleSource)
    Deprecated.
    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
    Parameters:
      `name` - The name.
      `ruleSource` - A rule source class.
    Since:
      2.5

  - ### beforeEach

    void beforeEach(Action<? super T> configAction)
    Deprecated.
    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)`.

    Parameters:
      `configAction` - An action that configures the item. The action is executed when the item is required.
    Since:
      2.5

  - ### beforeEach

    <S> void beforeEach(Class<S> type, Action<? super S> configAction)
    Deprecated.
    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)`.

    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.
    Since:
      2.5

  - ### all

    void all(Action<? super T> configAction)
    Deprecated.
    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)`.

    Parameters:
      `configAction` - An action that configures the item. The action is executed when the item is required.
    Since:
      2.5

  - ### withType

    <S> void withType(Class<S> type, Action<? super S> configAction)
    Deprecated.
    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)`.

    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.
    Since:
      2.5

  - ### withType

    <S> void withType(Class<S> type, Class<? extends RuleSource> rules)
    Deprecated.
    Applies the given rules to all items of the collection of the given type.
    Parameters:
      `type` - the type that the item must be/implement to have the rules applied
      `rules` - rules to apply
    Since:
      2.5

  - ### afterEach

    void afterEach(Action<? super T> configAction)
    Deprecated.
    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.

    Parameters:
      `configAction` - An action that configures the item. The action is executed when the item is required.
    Since:
      2.5

  - ### afterEach

    <S> void afterEach(Class<S> type, Action<? super S> configAction)
    Deprecated.
    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.

    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.
    Since:
      2.5

  - ### values

    Collection<T> values()
    Deprecated.
    Returns the items in this collection.
    Returns:
      The items.
    Since:
      2.5