Class Assert

java.lang.Object
com.datastax.astra.internal.utils.Assert

public class Assert extends Object
Syntaxic sugar for common validations.
Author:
Cedrick LUNVEN (@clunven)
  • Method Details

    • hasLength

      public static void hasLength(String s, String name)
      Validates that the input string is not null and not empty.

      This method is used to enforce preconditions on string parameters, ensuring they contain meaningful content before processing.

      Parameters:
      s - the string value to validate
      name - the parameter name to include in the error message
      Throws:
      IllegalArgumentException - if the string is null or empty
    • notNull

      public static void notNull(Object o, String name)
      Validates that the input object is not null.

      This method is used to enforce preconditions on object parameters, ensuring they are properly initialized before use.

      Parameters:
      o - the object value to validate
      name - the parameter name to include in the error message
      Throws:
      IllegalArgumentException - if the object is null
    • isTrue

      public static void isTrue(boolean condition, String msg)
      Check condition at start.
      Parameters:
      condition - predicate should be true
      msg - error message