Package org.gradle.language

## Interface BinaryCollection<T extends SoftwareComponent>

- Type Parameters:
    `T` - type of the elements in this container.

      public interface BinaryCollection<T extends SoftwareComponent>

  A collection of binaries that are created and configured as they are required.

  Each element in this collection passes through several states. The element is created and becomes 'known'. The element is passed to any actions registered using `whenElementKnown(Action)`. The element is then configured using any actions registered using `configureEach(Action)` and becomes 'finalized'. The element is passed to any actions registered using `whenElementFinalized(Action)`. Elements are created and configured only when required.

  Since:
    4.5

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<S> void` | `configureEach​(java.lang.Class<S> type, Action<? super S> action)` | Registers an action to execute to configure each element of the given type in the collection.
    `void` | `configureEach​(Action<? super T> action)` | Registers an action to execute to configure each element in the collection.
    `java.util.Set<T>` | `get()` | Returns the set of binaries from this collection.
    `<S> BinaryProvider<S>` | `get​(java.lang.Class<S> type, Spec<? super S> spec)` | Returns a `BinaryProvider` that contains the single binary matching the specified type and specification.
    `BinaryProvider<T>` | `get​(Spec<? super T> spec)` | Returns a `Provider` that contains the single binary matching the given specification.
    `BinaryProvider<T>` | `getByName​(java.lang.String name)` | Returns a `BinaryProvider` that contains the single binary with the given name.
    `<S> void` | `whenElementFinalized​(java.lang.Class<S> type, Action<? super S> action)` | Registers an action to execute when an element of the given type is finalized.
    `void` | `whenElementFinalized​(Action<? super T> action)` | Registers an action to execute when an element is finalized.
    `<S> void` | `whenElementKnown​(java.lang.Class<S> type, Action<? super S> action)` | Registers an action to execute when an element of the given type becomes known.
    `void` | `whenElementKnown​(Action<? super T> action)` | Registers an action to execute when an element becomes known.

- - ### Method Detail

    - #### get

          <S> BinaryProvider<S> get​(java.lang.Class<S> type,
                                    Spec<? super S> spec)

      Returns a `BinaryProvider` that contains the single binary matching the specified type and specification. The binary will be in the finalized state. The provider can be used to apply configuration to the element before it is finalized.

      Querying the return value will fail when there is not exactly one matching binary.

      Type Parameters:
        `S` - type of the binary to return
      Parameters:
        `type` - type to match
        `spec` - specification to satisfy. The spec is applied to each binary prior to configuration.
      Returns:
        a binary from the collection in a finalized state

    - #### getByName

          BinaryProvider<T> getByName​(java.lang.String name)

      Returns a `BinaryProvider` that contains the single binary with the given name. The binary will be in the finalized state. The provider can be used to apply configuration to the element before it is finalized.

      Querying the return value will fail when there is not exactly one matching binary.

      Parameters:
        `name` - The name of the binary
      Returns:
        a binary from the collection in a finalized state

    - #### get

          BinaryProvider<T> get​(Spec<? super T> spec)

      Returns a `Provider` that contains the single binary matching the given specification. The binary will be in the finalized state. The provider can be used to apply configuration to the element before it is finalized.

      Querying the return value will fail when there is not exactly one matching binary.

      Parameters:
        `spec` - specification to satisfy. The spec is applied to each binary prior to configuration.
      Returns:
        a binary from the collection in a finalized state

    - #### whenElementKnown

          void whenElementKnown​(Action<? super T> action)

      Registers an action to execute when an element becomes known. The action is only executed for those elements that are required. Fails if any element has already been finalized.
      Parameters:
        `action` - The action to execute for each element becomes known.

    - #### whenElementKnown

          <S> void whenElementKnown​(java.lang.Class<S> type,
                                    Action<? super S> action)

      Registers an action to execute when an element of the given type becomes known. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.
      Parameters:
        `type` - The type of element to select.
        `action` - The action to execute for each element becomes known.

    - #### whenElementFinalized

          void whenElementFinalized​(Action<? super T> action)

      Registers an action to execute when an element is finalized. The action is only executed for those elements that are required. Fails if any element has already been finalized.
      Parameters:
        `action` - The action to execute for each element when finalized.

    - #### whenElementFinalized

          <S> void whenElementFinalized​(java.lang.Class<S> type,
                                        Action<? super S> action)

      Registers an action to execute when an element of the given type is finalized. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.
      Parameters:
        `type` - The type of element to select.
        `action` - The action to execute for each element when finalized.

    - #### configureEach

          void configureEach​(Action<? super T> action)

      Registers an action to execute to configure each element in the collection. The action is only executed for those elements that are required. Fails if any element has already been finalized.
      Parameters:
        `action` - The action to execute on each element for configuration.

    - #### configureEach

          <S> void configureEach​(java.lang.Class<S> type,
                                 Action<? super S> action)

      Registers an action to execute to configure each element of the given type in the collection. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.
      Parameters:
        `type` - The type of element to select.
        `action` - The action to execute on each element for configuration.

    - #### get

          java.util.Set<T> get()

      Returns the set of binaries from this collection. Elements are in a finalized state.