Class CodeValidation

    • Constructor Summary

      Constructors 
      Constructor Description
      CodeValidation()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String check​(java.lang.String code)
      Checks if a specific code is valid.
      boolean isLowercase​(java.lang.String code, int chars)
      Checks the length of a code and if a code consists of lowercase letters from a to z.
      boolean isNumeric​(java.lang.String code, int digits)
      Checks the length of a code and if a code consists of numbers only.
      boolean isUppercase​(java.lang.String code, int chars)
      Checks the length of a code and if a code consists of uppercase letters from A to Z.
      abstract boolean isValid​(java.lang.String code)
      Checks if a specific code is valid.
      • Methods inherited from class java.lang.Object

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

      • CodeValidation

        public CodeValidation()
    • Method Detail

      • isValid

        public abstract boolean isValid​(java.lang.String code)
        Checks if a specific code is valid.
        Parameters:
        code - the value you want to check
        Returns:
        true if the code is valid
      • check

        public java.lang.String check​(java.lang.String code)
                               throws InvalidCodeException
        Checks if a specific code is valid.
        Parameters:
        code - the value you want to check
        Returns:
        the code that has been checked
        Throws:
        InvalidCodeException - reveals the reason why the code isn't valid
      • isNumeric

        public boolean isNumeric​(java.lang.String code,
                                 int digits)
        Checks the length of a code and if a code consists of numbers only.
        Parameters:
        code - the code that needs to be checked
        digits - the expected length of the code
        Returns:
        true if the code is numeric and has the expected length
      • isUppercase

        public boolean isUppercase​(java.lang.String code,
                                   int chars)
        Checks the length of a code and if a code consists of uppercase letters from A to Z.
        Parameters:
        code - the code that needs to be checked
        chars - the expected length of the code
        Returns:
        true if the code consists of letters from A to Z and has the expected length
      • isLowercase

        public boolean isLowercase​(java.lang.String code,
                                   int chars)
        Checks the length of a code and if a code consists of lowercase letters from a to z.
        Parameters:
        code - the code that needs to be checked
        chars - the expected length of the code
        Returns:
        true if the code consists of letters from a to z and has the expected length