From 6565989a6187cc32240920606f1b270c772c83dc Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 1 Oct 2015 20:46:22 +0300 Subject: [PATCH] Drop deprecated API: Comparators --- libraries/stdlib/src/kotlin/util/Ordering.kt | 31 +++----------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/libraries/stdlib/src/kotlin/util/Ordering.kt b/libraries/stdlib/src/kotlin/util/Ordering.kt index 997fa671d84..272c47661c8 100644 --- a/libraries/stdlib/src/kotlin/util/Ordering.kt +++ b/libraries/stdlib/src/kotlin/util/Ordering.kt @@ -19,26 +19,9 @@ package kotlin import java.util.Comparator -/** - * Compares two values using the specified sequence of functions to calculate the result of the comparison. - * The functions are called sequentially, receive the given values [a] and [b] and return [Comparable] - * objects. As soon as the [Comparable] instances returned by a function for [a] and [b] values do not - * compare as equal, the result of that comparison is returned. - */ -@Deprecated("Use selector functions accepting nullable T as a receiver.") -public fun compareValuesBy(a: T?, b: T?, vararg functions: (T) -> Comparable<*>?): Int { - require(functions.size() > 0) - if (a === b) return 0 - if (a == null) return -1 - if (b == null) return 1 - for (fn in functions) { - val v1 = fn(a) - val v2 = fn(b) - val diff = compareValues(v1, v2) - if (diff != 0) return diff - } - return 0 -} +@HiddenDeclaration +@Deprecated("Use compareValuesBy", ReplaceWith("compareValuesBy(a, b, *selectors)")) +public fun compareValuesByNullable(a: T, b: T, vararg selectors: (T) -> Comparable<*>?): Int = compareValuesBy(a, b, *selectors) /** * Compares two values using the specified functions [selectors] to calculate the result of the comparison. @@ -46,8 +29,6 @@ public fun compareValuesBy(a: T?, b: T?, vararg functions: (T) -> Comp * objects. As soon as the [Comparable] instances returned by a function for [a] and [b] values do not * compare as equal, the result of that comparison is returned. */ -// TODO: Remove platformName after M13 -@kotlin.jvm.JvmName("compareValuesByNullable") public fun compareValuesBy(a: T, b: T, vararg selectors: (T) -> Comparable<*>?): Int { require(selectors.size() > 0) for (fn in selectors) { @@ -110,11 +91,7 @@ public fun compareBy(vararg selectors: (T) -> Comparable<*>?): Comparator } } -/** - * Creates a comparator using the sequence of functions to calculate a result of comparison. - */ -@Deprecated("Use compareBy() instead", ReplaceWith("compareBy(*functions)")) -public fun comparator(vararg functions: (T) -> Comparable<*>?): Comparator = compareBy(*functions) + /** * Creates a comparator using the function to transform value to a [Comparable] instance for comparison.