# Interface DisambiguationRuleChain<T>

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

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.

Since:
  3.3

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(Class<? extends AttributeDisambiguationRule<T>> ruleClass)`
  Adds an arbitrary disambiguation rule to the chain.
  `void`
  `add(Class<? extends AttributeDisambiguationRule<T>> ruleClass, Action<? super ActionConfiguration> configureAction)`
  Adds an arbitrary disambiguation rule to the chain, possibly configuring the rule as well.
  `void`
  `pickFirst(Comparator<? super T> comparator)`
  Adds an ordered disambiguation rule.
  `void`
  `pickLast(Comparator<? super T> comparator)`
  Adds an ordered disambiguation rule.

- ## Method Details

  - ### add

    void add(Class<? extends AttributeDisambiguationRule<T>> ruleClass)

    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 `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:
      `ruleClass` - the rule to add
    Since:
      4.0

  - ### add

    void add(Class<? extends AttributeDisambiguationRule<T>> ruleClass, Action<? super ActionConfiguration> configureAction)

    Adds an arbitrary disambiguation rule to the chain, possibly configuring the rule as well.

    Parameters:
      `ruleClass` - the rule to add
      `configureAction` - the action to use to configure the rule
    Since:
      4.0

  - ### 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
    Since:
      3.3

  - ### 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
    Since:
      3.3