Restore isNotEmpty and isNotBlank methods for non-nullable String receiver.

#KT-7234 Fixed
This commit is contained in:
Ilya Gorbunov
2015-05-08 23:08:23 +03:00
parent 771af78b06
commit 7721efad8a
@@ -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.
*/