org.gradle.api.attributes

## Interface DisambiguationRuleChain<T>

- Type Parameters:
    `T` - the concrete type of the attribute

      @Incubating
      public interface DisambiguationRuleChain<T>

  A chain of disambiguation rules. By default the chain is empty and will not do any disambiguation.

  For a given set of rules, the execution is done in order, and interrupts as soon as a rule selected at least one candidate (through `MultipleCandidatesDetails.closestMatch(Object)`).

  If the end of the rule chain is reached and that no rule selected a candidate then the candidate list is returned unmodified, meaning we still have an ambiguous match.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(Action<? super MultipleCandidatesDetails<T>> rule)` Adds an arbitrary disambiguation rule to the chain.
    `void` | `pickFirst(Comparator<? super T> comparator)` Adds an ordered disambiguation rule.
    `void` | `pickLast(Comparator<? super T> comparator)` Adds an ordered disambiguation rule.

- - ### Method Detail

    - #### add

          void add(Action<? super MultipleCandidatesDetails<T>> rule)

      Adds an arbitrary disambiguation rule to the chain.

      A disambiguation rule can select the best match from a list of candidates.

      A rule can express an preference by calling the @{link `MultipleCandidatesDetails.closestMatch(Object)` method to tell that a candidate is the best one.

      It is not mandatory for a rule to choose, and it is not an error to select multiple candidates.

      Parameters:
        `rule` - the rule to add

    - #### pickFirst

          void pickFirst(Comparator<? super T> comparator)

      Adds an ordered disambiguation rule. Values will be compared using the provided comparator, and the rule will automatically select the first value (if multiple candidates have the same attribute value, there will still be an ambiguity).
      Parameters:
        `comparator` - the comparator to use

    - #### pickLast

          void pickLast(Comparator<? super T> comparator)

      Adds an ordered disambiguation rule. Values will be compared using the provided comparator, and the rule will automatically select the last value (if multiple candidates have the same attribute value, there will still be an ambiguity).
      Parameters:
        `comparator` - the comparator to use