Class Assert

java.lang.Object
io.fliqa.client.interledger.utils.Assert

public final class Assert extends Object
Utility class providing assertion methods for input validation.

This class provides a collection of static assertion methods used throughout the Interledger client for validating method parameters and preventing invalid states. All assertion methods throw IllegalArgumentException by default or can accept custom exception suppliers for specific error handling.

Common Usage


 public void processPayment(PaymentPointer wallet, BigDecimal amount) {
     Assert.notNull(wallet, "Wallet cannot be null");
     Assert.isTrue(amount.compareTo(BigDecimal.ZERO) > 0, "Amount must be positive");
 }
 
Since:
1.0
  • Method Details

    • isTrue

      public static void isTrue(boolean value, String message)
      Asserts that a boolean condition is true.
      Parameters:
      value - the boolean condition to check
      message - the error message if the condition is false
      Throws:
      IllegalArgumentException - if the condition is false
    • isTrue

      public static <E extends Throwable> void isTrue(boolean value, Supplier<E> exceptionSupplier) throws E
      Throws:
      E
    • isFalse

      public static void isFalse(boolean value, String message)
      Asserts that a boolean condition is false.
      Parameters:
      value - the boolean condition to check
      message - the error message if the condition is true
      Throws:
      IllegalArgumentException - if the condition is true
    • isFalse

      public static <E extends Throwable> void isFalse(boolean value, Supplier<E> exceptionSupplier) throws E
      Throws:
      E
    • notNull

      public static void notNull(Object value, String message)
      Asserts that an object is not null.
      Parameters:
      value - the object to check
      message - the error message if the object is null
      Throws:
      IllegalArgumentException - if the object is null
    • notNull

      public static <E extends Throwable> void notNull(Object value, Supplier<E> exceptionSupplier) throws E
      Throws:
      E
    • notNullOrEmpty

      public static void notNullOrEmpty(String value, String message)
      Asserts that a string is not null and not blank.
      Parameters:
      value - the string to check
      message - the error message if the string is null or blank
      Throws:
      IllegalArgumentException - if the string is null or blank
    • notNullOrEmpty

      public static <T> void notNullOrEmpty(Set<T> value, String message)
    • notNullOrEmpty

      public static <E extends Throwable> void notNullOrEmpty(String value, Supplier<E> exceptionSupplier) throws E
      Throws:
      E
    • notNullOrEmpty

      public static <K, V> void notNullOrEmpty(Map<K,V> value, String message)
    • notNullOrEmpty

      public static <E extends Throwable, T> void notNullOrEmpty(List<T> value, Supplier<E> exceptionSupplier) throws E
      Throws:
      E
    • notNullOrEmpty

      public static <E extends Throwable, T> void notNullOrEmpty(Set<T> value, Supplier<E> exceptionSupplier) throws E
      Throws:
      E