spring-framework / org.springframework.util / Assert / isTrue

isTrue

open static fun isTrue(expression: Boolean, message: String): Unit

Assert a boolean expression, throwing an IllegalArgumentException if the expression evaluates to false.

Assert.isTrue(i > 0, "The value must be greater than zero");

Parameters

expression - a boolean expression

message - the exception message to use if the assertion fails

Exceptions

IllegalArgumentException - if expression is false

open static fun isTrue(expression: Boolean, messageSupplier: Supplier<String>): Unit

Assert a boolean expression, throwing an IllegalArgumentException if the expression evaluates to false.

 Assert.isTrue(i > 0, () -> "The value '" + i + "' must be greater than zero"); 

Parameters

expression - a boolean expression

messageSupplier - a supplier for the exception message to use if the assertion fails

Exceptions

IllegalArgumentException - if expression is false

Since
5.0

open static fun isTrue(expression: Boolean): Unit