ComponentSelection (Gradle API 9.7.1)
Description: declaration: package: org.gradle.api.artifacts, interface: ComponentSelection

# Interface ComponentSelection

public interface ComponentSelection
Represents a tuple of the component selector of a module and a candidate version to be evaluated in a component selection rule.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ModuleComponentIdentifier`
  `getCandidate()`
  Gets the candidate version of the module.
  `<T> @Nullable T`
  `getDescriptor(Class<T> descriptorClass)`
  Used to access a specific descriptor format.
  `@Nullable ComponentMetadata`
  `getMetadata()`
  Gets the metadata of the component.
  `void`
  `reject(String reason)`
  Rejects the candidate for the resolution.

- ## Method Details

  - ### getCandidate

    ModuleComponentIdentifier getCandidate()
    Gets the candidate version of the module.
    Returns:
      the candidate version of the module

  - ### getMetadata

    @Nullable ComponentMetadata getMetadata()
    Gets the metadata of the component.

    The metadata may not be available, in which case `null` is returned. Unavailable metadata may be caused by a module published without associated metadata.

    Returns:
      the `ComponentMetadata` or `null` if not available
    Since:
      5.0

  - ### getDescriptor

    <T> @Nullable T getDescriptor(Class<T> descriptorClass)
    Used to access a specific descriptor format.

    For an Ivy module, an `ivy module descriptor` can be requested and returned.

    If the descriptor type requested does not exist for the module under selection, `null` is returned.

    Type Parameters:
      `T` - the descriptor type
    Parameters:
      `descriptorClass` - the descriptor class
    Returns:
      a descriptor fo the requested type, or `null` if there was none of the requested type.
    Since:
      5.0
    See Also:
      - `IvyModuleDescriptor`

  - ### reject

    void reject(String reason)
    Rejects the candidate for the resolution.
    Parameters:
      `reason` - The reason the candidate was rejected.