Class Assert

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

public class Assert extends Object
Assert
Author:
Leonard Woo
  • 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.
    • hasLength

      public static void hasLength(String text, String message)
      if string text length is 0 throw message
      Parameters:
      text - string text.
      message - message.
      Throws:
      NullPointerException - 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:
      NullPointerException - if text have not any char 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.