create
Creates a NotBlankString from the string representation of the specified value, or throws an IllegalArgumentException if its string representation is blank.
Calling from Kotlin
Here's an example of calling this method from Kotlin code:
val isSuccess: Boolean = try {
NotBlankString.create("Kotools Types")
true
} catch (exception: IllegalArgumentException) {
false
}
assertTrue(isSuccess)
Content copied to clipboard
The NotBlankString type being an inline value class, this method is not available yet for Java users.
You can use the NotBlankString.Companion.createOrNull method for returning null
instead of throwing an exception in case of invalid value.