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

hasText

open static fun hasText(@Nullable text: String, message: String): Unit

Assert that the given String contains valid text content; that is, it must not be null and must contain at least one non-whitespace character.

Assert.hasText(name, "'name' must not be empty");

Parameters

text - the String to check

message - the exception message to use if the assertion fails

Exceptions

IllegalArgumentException - if the text does not contain valid text content

See Also
StringUtils#hasText

open static fun hasText(@Nullable text: String, messageSupplier: Supplier<String>): Unit

Assert that the given String contains valid text content; that is, it must not be null and must contain at least one non-whitespace character.

 Assert.hasText(name, () -> "Name for account '" + account.getId() + "' must not be empty"); 

Parameters

text - the String to check

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

Exceptions

IllegalArgumentException - if the text does not contain valid text content

See Also
StringUtils#hasText

Since
5.0

open static fun hasText(@Nullable text: String): Unit