Class Assert
java.lang.Object
io.fliqa.client.interledger.utils.Assert
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 Summary
Modifier and TypeMethodDescriptionstatic voidAsserts that a boolean condition is false.static <E extends Throwable>
voidstatic voidAsserts that a boolean condition is true.static <E extends Throwable>
voidstatic voidAsserts that an object is not null.static <E extends Throwable>
voidstatic voidnotNullOrEmpty(String value, String message) Asserts that a string is not null and not blank.static <E extends Throwable>
voidnotNullOrEmpty(String value, Supplier<E> exceptionSupplier) static <E extends Throwable,T>
voidnotNullOrEmpty(List<T> value, Supplier<E> exceptionSupplier) static <K,V> void notNullOrEmpty(Map<K, V> value, String message) static <T> voidnotNullOrEmpty(Set<T> value, String message) static <E extends Throwable,T>
voidnotNullOrEmpty(Set<T> value, Supplier<E> exceptionSupplier)
-
Method Details
-
isTrue
Asserts that a boolean condition is true.- Parameters:
value- the boolean condition to checkmessage- 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
Asserts that a boolean condition is false.- Parameters:
value- the boolean condition to checkmessage- 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
Asserts that an object is not null.- Parameters:
value- the object to checkmessage- 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
Asserts that a string is not null and not blank.- Parameters:
value- the string to checkmessage- the error message if the string is null or blank- Throws:
IllegalArgumentException- if the string is null or blank
-
notNullOrEmpty
-
notNullOrEmpty
public static <E extends Throwable> void notNullOrEmpty(String value, Supplier<E> exceptionSupplier) throws E - Throws:
E
-
notNullOrEmpty
-
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
-