Class OptionValidator


  • final class OptionValidator
    extends java.lang.Object
    Validates an Option string.
    Since:
    1.1
    • Constructor Summary

      Constructors 
      Constructor Description
      OptionValidator()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean isValidChar​(char c)
      Returns whether the specified character is a valid character.
      private static boolean isValidOpt​(char c)
      Returns whether the specified character is a valid Option.
      (package private) static java.lang.String validate​(java.lang.String option)
      Validates whether opt is a permissible Option shortOpt.
      • Methods inherited from class java.lang.Object

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

      • OptionValidator

        OptionValidator()
    • Method Detail

      • isValidChar

        private static boolean isValidChar​(char c)
        Returns whether the specified character is a valid character.
        Parameters:
        c - the character to validate
        Returns:
        true if c is a letter.
      • isValidOpt

        private static boolean isValidOpt​(char c)
        Returns whether the specified character is a valid Option.
        Parameters:
        c - the option to validate
        Returns:
        true if c is a letter, '?' or '@', otherwise false.
      • validate

        static java.lang.String validate​(java.lang.String option)
                                  throws java.lang.IllegalArgumentException
        Validates whether opt is a permissible Option shortOpt. The rules that specify if the opt is valid are:
        • a single character opt that is either ' '(special case), '?', '@' or a letter
        • a multi character opt that only contains letters.

        In case opt is null no further validation is performed.

        Parameters:
        option - The option string to validate, may be null
        Throws:
        java.lang.IllegalArgumentException - if the Option is not valid.