Class DefaultMatcher<TOption>

  • Type Parameters:
    TOption - Option type
    All Implemented Interfaces:
    PromptOptionMatcher<TOption>
    Direct Known Subclasses:
    ExactMatcher, IgnoresCaseMatcher

    public class DefaultMatcher<TOption>
    extends java.lang.Object
    implements PromptOptionMatcher<TOption>
    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 
      Constructor Description
      DefaultMatcher()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.apache.commons.collections4.Predicate<TOption> getExactMatcher​(java.lang.String response)
      Gets an exact matcher
      protected org.apache.commons.collections4.Predicate<TOption> getExactOrPartialMatcher​(java.lang.String response)
      Gets an exact or partial matcher
      TOption match​(Prompt<TOption> prompt, java.lang.String response)
      Matches the response to an option provided by the prompt
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultMatcher

        public DefaultMatcher()
    • Method Detail

      • match

        public TOption match​(Prompt<TOption> prompt,
                             java.lang.String response)
                      throws PromptException
        Description copied from interface: PromptOptionMatcher
        Matches the response to an option provided by the prompt
        Specified by:
        match in interface PromptOptionMatcher<TOption>
        Parameters:
        prompt - Prompt
        response - 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

        protected org.apache.commons.collections4.Predicate<TOption> getExactMatcher​(java.lang.String response)
        Gets an exact matcher
        Parameters:
        response - User response to match options against
        Returns:
        Exact matcher
      • getExactOrPartialMatcher

        protected org.apache.commons.collections4.Predicate<TOption> getExactOrPartialMatcher​(java.lang.String response)
        Gets an exact or partial matcher
        Parameters:
        response - User response to match options against
        Returns:
        Exact or partial matcher