NotBlankString

@Serializable(with = NotBlankStringSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
value class NotBlankString : Comparable<NotBlankString>

Represents a string that has at least one character excluding whitespaces.

You can use the toNotBlankString method for creating an instance of this type.


Serialization and deserialization

The serialization and deserialization processes of this type behave like for the String type.

Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:

val string: NotBlankString = "hello world".toNotBlankString()
.getOrThrow()
val encoded: String = Json.encodeToString(string)
assertEquals(expected = "\"hello world\"", actual = encoded)
val decoded: NotBlankString = Json.decodeFromString(encoded)
assertEquals(expected = string, actual = decoded)

Types

Link copied to clipboard
object Companion

Contains static declarations for the NotBlankString type.

Properties

Link copied to clipboard

Returns the length of this string.

Functions

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
open infix operator override fun compareTo(other: NotBlankString): Int

Compares this string alphabetically with the other one for order. Returns zero if this string equals the other one, a negative number if it's less than the other one, or a positive number if it's greater than the other one.

Link copied to clipboard
@ExperimentalSince(version = KotoolsTypesVersion.V4_5_0)
operator fun plus(other: Any): NotBlankString

Concatenates this string with the string representation of the other object.

Link copied to clipboard
open override fun toString(): String

Returns this string as a String.