Class ValueMatcher<TOption>

  • Type Parameters:
    TOption - Option type
    All Implemented Interfaces:
    PromptOptionMatcher<TOption>

    public class ValueMatcher<TOption>
    extends java.lang.Object
    implements PromptOptionMatcher<TOption>
    An option matcher that matches based on actual value rather than strings

    This allows for matching options where there are multiple ways of writing down a value. For example if you have an option that is specified as a numeric value there could be multiple ways to specify the number e.g. 1.0, 1, 1.0e0 etc.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class<TOption> optionType  
    • Constructor Summary

      Constructors 
      Constructor Description
      ValueMatcher​(java.lang.Class<TOption> optionType)
      Creates a new value matcher
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
    • Field Detail

      • optionType

        private final java.lang.Class<TOption> optionType
    • Constructor Detail

      • ValueMatcher

        public ValueMatcher​(java.lang.Class<TOption> optionType)
        Creates a new value matcher
        Parameters:
        optionType - Option class
    • 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