Class Contract

java.lang.Object
com.avoka.tm.util.Contract

public class Contract extends Object

Provides design by contract programming validation functions.

Since:
5.0.0
  • Method Details

    • isTrue

      public static void isTrue(boolean value, String message)
      Ensure the specified condition value is true, or throw an IllegalArgumentExcpetion if false.
      Parameters:
      value - the conditional value to test
      message - the IllegalArgumentException message if the conditional value is false
    • notNull

      public static void notNull(Object paramValue, String paramName)
      Validate specified parameter is not null, throw a IllegalArgumentException if null.
      Parameters:
      paramValue - the parameter value to verify not null
      paramName - the parameter name
    • notBlank

      public static void notBlank(String paramValue, String paramName)
      Validate specified parameter is not null, or blank throw a IllegalArgumentException if null or blank.
      Parameters:
      paramValue - the parameter value to verify not null, or blank
      paramName - the parameter name
    • checkSpecialChars

      public static boolean checkSpecialChars(String regex, String text)
      Search text for characters
      Parameters:
      regex - regular expression
      text - the searched text
      Since:
      23.10.0
    • checkReservedWords

      public static boolean checkReservedWords(String[] reservedWords, String word)
      Check a word against a blacklist or whitelist of reserved words
      Parameters:
      reservedWords - list of string
      word - the string to be checked
      Since:
      23.10.0