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:
Ilya Gorbunov
2015-06-03 19:41:03 +03:00
parent 13c89b7ae9
commit 705c9089f0
4 changed files with 9 additions and 15 deletions
@@ -52,14 +52,8 @@ public inline fun String.findNot(predicate: (Char) -> Boolean): Char? {
/**
* A helper method for creating a [[Runnable]] from a function
*/
deprecated("Use SAM constructor: Runnable(...)")
public /*inline*/ fun runnable(action: () -> Unit): Runnable {
return object: Runnable {
public override fun run() {
action()
}
}
}
deprecated("Use SAM constructor: Runnable(...)", ReplaceWith("Runnable(action)"))
public /*inline*/ fun runnable(action: () -> Unit): Runnable = Runnable(action)
deprecated("Use forEachIndexed instead.", ReplaceWith("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
*/
deprecated("Use SAM constructor: Callable(...)")
public /*inline*/ fun <T> callable(action: () -> T): Callable<T> {
return object: Callable<T> {
public override fun call() = action()
}
}
deprecated("Use SAM constructor: Callable(...)", ReplaceWith("Callable(action)", "java.util.concurrent.Callable"))
public /*inline*/ fun <T> callable(action: () -> T): Callable<T> = Callable(action)
deprecated("Use length() instead", ReplaceWith("length()"))
public val String.size: Int
+1 -1
View File
@@ -149,7 +149,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.")
deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.", ReplaceWith("this != null && this.isNotEmpty()"))
platformName("isNotEmptyNullable")
public fun String?.isNotEmpty(): Boolean = this != null && this.length() > 0