Class PreConditions

java.lang.Object
com.github.mjeanroy.dbunit.commons.lang.PreConditions

public final class PreConditions extends Object
Static PreConditions Utilities.
  • Method Details

    • notNull

      public static <T> T notNull(T value, String message, Object... params)
      Ensure that given value is not null.
      Type Parameters:
      T - Type of value.
      Parameters:
      value - Value to check.
      message - Error message.
      params - Optional error message parameters.
      Returns:
      Value if it is not null.
      Throws:
      NullPointerException - If value is null.
    • notBlank

      public static String notBlank(String value, String message, Object... params)
      Ensure that given value is not null, empty or blank.
      Parameters:
      value - Value to check.
      message - Error message.
      params - Optional error message parameters.
      Returns:
      Value if it is not null, empty or blank.
      Throws:
      NullPointerException - If value is null.
      IllegalArgumentException - If value is empty or blank.
    • notBlank

      public static char notBlank(char value, String message, Object... params)
      Ensure that given value is not blank.
      Parameters:
      value - Value to check.
      message - Error message.
      params - Optional error message parameters.
      Returns:
      Value if it is not null, empty or blank.
      Throws:
      NullPointerException - If value is null.
      IllegalArgumentException - If value is empty or blank.
    • startsWith

      public static String startsWith(String value, String prefix, String message, Object... params)
      Ensure that given value is not null, empty or blank and starts with given prefix.
      Parameters:
      value - Value to check.
      prefix - The prefix to look for.
      message - Error message.
      params - Optional error message parameters.
      Returns:
      Value if it is not null, empty or blank.
      Throws:
      NullPointerException - If value is null.
      IllegalArgumentException - If value is empty, blank, or does not start with prefix.
    • checkArgument

      public static void checkArgument(boolean condition, String message, Object... params)
      Check argument condition and throw IllegalArgumentException if condition is false.
      Parameters:
      condition - The result of the condition to verify.
      message - Error message.
      params - Optional error message parameters.