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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(java.lang.Class<? extends AttributeDisambiguationRule<T>> rule)
Adds an arbitrary disambiguation rule to the chain.void
add(java.lang.Class<? extends AttributeDisambiguationRule<T>> rule, Action<? super ActionConfiguration> configureAction)
Adds an arbitrary disambiguation rule to the chain, possibly configuring the rule as well.void
pickFirst(java.util.Comparator<? super T> comparator)
Adds an ordered disambiguation rule.void
pickLast(java.util.Comparator<? super T> comparator)
Adds an ordered disambiguation rule.
-
-
-
Method Detail
-
add
void add(java.lang.Class<? extends AttributeDisambiguationRule<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- Since:
- 4.0
-
add
void add(java.lang.Class<? extends AttributeDisambiguationRule<T>> rule, Action<? super ActionConfiguration> configureAction)
Adds an arbitrary disambiguation rule to the chain, possibly configuring the rule as well.
- Parameters:
rule
- the rule to addconfigureAction
- the action to use to configure the rule- Since:
- 4.0
-
pickFirst
void pickFirst(java.util.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(java.util.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
-
-