Class DefaultMatcher<TOption>
java.lang.Object
com.github.rvesse.airline.prompts.matchers.DefaultMatcher<TOption>
- Type Parameters:
TOption
- Option type
- All Implemented Interfaces:
PromptOptionMatcher<TOption>
- Direct Known Subclasses:
ExactMatcher
,IgnoresCaseMatcher
Default prompt option matcher
This matcher tries to find the most likely options using either exact matching or partial matching. It also allows for numeric option selection when the prompt has enabled that feature.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.commons.collections4.Predicate
<TOption> getExactMatcher
(String response) Gets an exact matcherprotected org.apache.commons.collections4.Predicate
<TOption> getExactOrPartialMatcher
(String response) Gets an exact or partial matcherMatches the response to an option provided by the prompt
-
Constructor Details
-
DefaultMatcher
public DefaultMatcher()
-
-
Method Details
-
match
Description copied from interface:PromptOptionMatcher
Matches the response to an option provided by the prompt- Specified by:
match
in interfacePromptOptionMatcher<TOption>
- Parameters:
prompt
- Promptresponse
- Response value that has been read from the prompt- Returns:
- Matched option
- Throws:
PromptException
- Thrown if the response value does not match any option, or if the matcher is not compatible with the prompt
-
getExactMatcher
Gets an exact matcher- Parameters:
response
- User response to match options against- Returns:
- Exact matcher
-
getExactOrPartialMatcher
protected org.apache.commons.collections4.Predicate<TOption> getExactOrPartialMatcher(String response) Gets an exact or partial matcher- Parameters:
response
- User response to match options against- Returns:
- Exact or partial matcher
-