Class Assert

java.lang.Object
org.seppiko.commons.utils.Assert

public class Assert extends Object
Assert
Author:
Leonard Woo
  • Constructor Details

    • Assert

      public Assert()
  • Method Details

    • isTrue

      public static void isTrue(boolean expression, String message)
      if not true throw message
      Parameters:
      expression - boolean expression
      message - message
      Throws:
      IllegalArgumentException - if expression is false throw this
    • isFalse

      public static void isFalse(boolean expression, String message)
      if true throw message
      Parameters:
      expression - boolean expression
      message - message
      Throws:
      IllegalArgumentException - if expression is true throw this
    • isNull

      public static void isNull(Object obj, String message)
      if object is not null throw message
      Parameters:
      obj - object
      message - message
      Throws:
      IllegalArgumentException - if object is not null throw this
    • notNull

      public static void notNull(Object obj, String message)
      if object is null throw message
      Parameters:
      obj - object
      message - message
      Throws:
      IllegalArgumentException - if object is null throw this
    • hasLength

      public static void hasLength(String text, String message)
      if string text length is 0 throw message
      Parameters:
      text - string text
      message - message
      Throws:
      IllegalArgumentException - if text have not any string throw this
    • hasText

      public static void hasText(String text, String message)
      if string text has not any char without whitespace throw message
      Parameters:
      text - string text
      message - message
      Throws:
      IllegalArgumentException - if text have not any char throw this
    • notEmpty

      public static void notEmpty(Object[] array, String message)
      if object array is null or length is 0 throw message
      Parameters:
      array - object array
      message - message
      Throws:
      IllegalArgumentException - if array is not empty throw this
    • sneakyThrow

      public static RuntimeException sneakyThrow(Throwable t)
      Throw exception with RuntimeException
      
        try {
          throw new Throwable();
        } catch (Throwable t) {
          throw Assert.sneakyThrow(t);
        }
       
      Parameters:
      t - any exception
      Returns:
      RuntimeException
      Throws:
      NullPointerException - if t is null throw this