Restore isNotEmpty and isNotBlank methods for non-nullable String receiver.
#KT-7234 Fixed
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package kotlin
|
||||
|
||||
import java.util.NoSuchElementException
|
||||
import kotlin.platform.platformName
|
||||
import kotlin.text.MatchResult
|
||||
import kotlin.text.Regex
|
||||
|
||||
@@ -149,6 +150,7 @@ public fun String.padEnd(length: Int, padChar: Char = ' '): String {
|
||||
|
||||
/** Returns true if the string is not null and not empty */
|
||||
deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.")
|
||||
platformName("isNotEmptyNullable")
|
||||
public fun String?.isNotEmpty(): Boolean = this != null && this.length() > 0
|
||||
|
||||
/**
|
||||
@@ -161,9 +163,20 @@ public fun String?.isNullOrEmpty(): Boolean = this == null || this.length() == 0
|
||||
*/
|
||||
public fun String.isEmpty(): Boolean = length() == 0
|
||||
|
||||
/**
|
||||
* Returns `true` if this string is not empty.
|
||||
*/
|
||||
public fun String.isNotEmpty(): Boolean = length() > 0
|
||||
|
||||
// implemented differently in JVM and JS
|
||||
//public fun String.isBlank(): Boolean = length() == 0 || all { it.isWhitespace() }
|
||||
|
||||
|
||||
/**
|
||||
* Returns `true` if this string is not empty and contains some characters except of whitespace characters.
|
||||
*/
|
||||
public fun String.isNotBlank(): Boolean = !isBlank()
|
||||
|
||||
/**
|
||||
* Returns `true` if this nullable string is either null or empty or consists solely of whitespace characters.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user