Provide replacement for methods deprecated in favor of SAM-constructors.
Provide replacement for isNotEmpty on nullable receiver. JS: Provide SAM-like constructor for Runnable.
This commit is contained in:
@@ -29,6 +29,10 @@ public trait Runnable {
|
|||||||
public open fun run() : Unit;
|
public open fun run() : Unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun Runnable(action: () -> Unit): Runnable = object : Runnable {
|
||||||
|
override fun run() = action()
|
||||||
|
}
|
||||||
|
|
||||||
library
|
library
|
||||||
public trait Appendable {
|
public trait Appendable {
|
||||||
public open fun append(csq: CharSequence?): Appendable
|
public open fun append(csq: CharSequence?): Appendable
|
||||||
|
|||||||
@@ -52,14 +52,8 @@ public inline fun String.findNot(predicate: (Char) -> Boolean): Char? {
|
|||||||
/**
|
/**
|
||||||
* A helper method for creating a [[Runnable]] from a function
|
* A helper method for creating a [[Runnable]] from a function
|
||||||
*/
|
*/
|
||||||
deprecated("Use SAM constructor: Runnable(...)")
|
deprecated("Use SAM constructor: Runnable(...)", ReplaceWith("Runnable(action)"))
|
||||||
public /*inline*/ fun runnable(action: () -> Unit): Runnable {
|
public /*inline*/ fun runnable(action: () -> Unit): Runnable = Runnable(action)
|
||||||
return object: Runnable {
|
|
||||||
public override fun run() {
|
|
||||||
action()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deprecated("Use forEachIndexed instead.", ReplaceWith("forEachIndexed(operation)"))
|
deprecated("Use forEachIndexed instead.", ReplaceWith("forEachIndexed(operation)"))
|
||||||
public inline fun <T> List<T>.forEachWithIndex(operation: (Int, T) -> Unit): Unit = forEachIndexed(operation)
|
public inline fun <T> List<T>.forEachWithIndex(operation: (Int, T) -> Unit): Unit = forEachIndexed(operation)
|
||||||
|
|||||||
@@ -31,12 +31,8 @@ public fun <K, V> sortedMap(vararg values: Pair<K, V>): SortedMap<K, V> = sorted
|
|||||||
/**
|
/**
|
||||||
* A helper method for creating a [[Callable]] from a function
|
* A helper method for creating a [[Callable]] from a function
|
||||||
*/
|
*/
|
||||||
deprecated("Use SAM constructor: Callable(...)")
|
deprecated("Use SAM constructor: Callable(...)", ReplaceWith("Callable(action)", "java.util.concurrent.Callable"))
|
||||||
public /*inline*/ fun <T> callable(action: () -> T): Callable<T> {
|
public /*inline*/ fun <T> callable(action: () -> T): Callable<T> = Callable(action)
|
||||||
return object: Callable<T> {
|
|
||||||
public override fun call() = action()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deprecated("Use length() instead", ReplaceWith("length()"))
|
deprecated("Use length() instead", ReplaceWith("length()"))
|
||||||
public val String.size: Int
|
public val String.size: Int
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public fun String.padEnd(length: Int, padChar: Char = ' '): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns `true` if the string is not `null` and not empty */
|
/** Returns `true` if the string is not `null` and not empty */
|
||||||
deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.")
|
deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.", ReplaceWith("this != null && this.isNotEmpty()"))
|
||||||
platformName("isNotEmptyNullable")
|
platformName("isNotEmptyNullable")
|
||||||
public fun String?.isNotEmpty(): Boolean = this != null && this.length() > 0
|
public fun String?.isNotEmpty(): Boolean = this != null && this.length() > 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user