Drop hidden declarations provided for binary compatibility

This commit is contained in:
Ilya Gorbunov
2016-01-14 23:16:12 +03:00
parent 264c9a0fc9
commit 85a02d40c6
25 changed files with 63 additions and 2092 deletions
@@ -15,8 +15,7 @@ fun aggregates(): List<GenericFunction> {
return true
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("none(predicate: (T) -> Boolean)") {
@@ -30,8 +29,7 @@ fun aggregates(): List<GenericFunction> {
return true
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("none()") {
@@ -43,8 +41,7 @@ fun aggregates(): List<GenericFunction> {
return true
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("any(predicate: (T) -> Boolean)") {
@@ -58,8 +55,7 @@ fun aggregates(): List<GenericFunction> {
return false
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("any()") {
@@ -71,8 +67,7 @@ fun aggregates(): List<GenericFunction> {
return false
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("count(predicate: (T) -> Boolean)") {
@@ -87,8 +82,7 @@ fun aggregates(): List<GenericFunction> {
return count
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("count()") {
@@ -101,9 +95,8 @@ fun aggregates(): List<GenericFunction> {
return count
"""
}
deprecate(Strings) { forBinaryCompatibility }
doc(CharSequences) { "Returns the length of this char sequence."}
body(CharSequences, Strings) {
body(CharSequences) {
"return length"
}
body(Maps, Collections, ArraysOfObjects, ArraysOfPrimitives) {
@@ -113,8 +106,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("sumBy(selector: (T) -> Int)") {
inline(true)
include(CharSequences, Strings)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences)
doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." }
returns("Int")
body {
@@ -130,8 +122,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("sumByDouble(selector: (T) -> Double)") {
inline(true)
include(CharSequences, Strings)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences)
doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." }
returns("Double")
body {
@@ -163,8 +154,7 @@ fun aggregates(): List<GenericFunction> {
return min
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty()) return null
var min = this[0]
@@ -201,8 +191,7 @@ fun aggregates(): List<GenericFunction> {
return minElem
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty()) return null
@@ -271,8 +260,7 @@ fun aggregates(): List<GenericFunction> {
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty()) return null
@@ -310,8 +298,7 @@ fun aggregates(): List<GenericFunction> {
return maxElem
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty()) return null
@@ -365,8 +352,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("fold(initial: R, operation: (R, T) -> R)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each ${f.element}." }
typeParam("R")
returns("R")
@@ -382,8 +368,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("foldRight(initial: R, operation: (T, R) -> R)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
doc { f -> "Accumulates value starting with [initial] value and applying [operation] from right to left to each ${f.element} and current accumulator value." }
typeParam("R")
returns("R")
@@ -402,8 +387,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("reduce(operation: (T, T) -> T)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
exclude(ArraysOfObjects, Iterables, Sequences)
doc { f -> "Accumulates value starting with the first ${f.element} and applying [operation] from left to right to current accumulator value and each ${f.element}." }
@@ -447,8 +431,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("reduceRight(operation: (T, T) -> T)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
only(CharSequences, Strings, ArraysOfPrimitives)
only(CharSequences, ArraysOfPrimitives)
doc { f -> "Accumulates value starting with last ${f.element} and applying [operation] from right to left to each ${f.element} and current accumulator value." }
returns("T")
body {
@@ -500,14 +483,12 @@ fun aggregates(): List<GenericFunction> {
for (element in this) action(element)
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("forEachIndexed(action: (Int, T) -> Unit)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}." }
returns("Unit")
body {
@@ -228,8 +228,7 @@ fun elements(): List<GenericFunction> {
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(Lists, CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects) {
body(Lists, CharSequences, ArraysOfPrimitives, ArraysOfObjects) {
"""
for (index in indices) {
if (predicate(this[index])) {
@@ -259,8 +258,7 @@ fun elements(): List<GenericFunction> {
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(Lists, CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects) {
body(Lists, CharSequences, ArraysOfPrimitives, ArraysOfObjects) {
"""
for (index in indices.reversed()) {
if (predicate(this[index])) {
@@ -289,8 +287,7 @@ fun elements(): List<GenericFunction> {
return elementAtOrElse(index) { throw IndexOutOfBoundsException("Sequence doesn't contain element at index $index.") }
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return get(index)
"""
@@ -330,9 +327,8 @@ fun elements(): List<GenericFunction> {
return defaultValue(index)
"""
}
deprecate(Strings) { forBinaryCompatibility }
inline(true, CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
inline(true, CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
"""
@@ -343,8 +339,7 @@ fun elements(): List<GenericFunction> {
doc { f -> "Returns ${f.element.prefixWithArticle()} at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this ${f.collection}." }
returns("T")
inline(true)
deprecate(Strings) { forBinaryCompatibility }
only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
body {
"""
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
@@ -386,8 +381,7 @@ fun elements(): List<GenericFunction> {
return null
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return if (index >= 0 && index <= lastIndex) get(index) else null
"""
@@ -397,8 +391,7 @@ fun elements(): List<GenericFunction> {
templates add f("getOrNull(index: Int)") {
doc { f -> "Returns ${f.element.prefixWithArticle()} at the given [index] or `null` if the [index] is out of bounds of this ${f.collection}." }
returns("T?")
deprecate(Strings) { forBinaryCompatibility }
only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
body {
"""
return if (index >= 0 && index <= lastIndex) get(index) else null
@@ -430,8 +423,7 @@ fun elements(): List<GenericFunction> {
}
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty())
throw NoSuchElementException("Collection is empty.")
@@ -468,8 +460,7 @@ fun elements(): List<GenericFunction> {
}
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return if (isEmpty()) null else this[0]
"""
@@ -487,8 +478,7 @@ fun elements(): List<GenericFunction> {
templates add f("first(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> """Returns the first ${f.element} matching the given [predicate].
@throws [NoSuchElementException] if no such ${f.element} is found.""" }
returns("T")
@@ -503,8 +493,7 @@ fun elements(): List<GenericFunction> {
templates add f("firstOrNull(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns the first ${f.element} matching the given [predicate], or `null` if ${f.element} was not found." }
returns("T?")
body {
@@ -517,8 +506,7 @@ fun elements(): List<GenericFunction> {
templates add f("find(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns the first ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." }
returns("T?")
body { "return firstOrNull(predicate)"}
@@ -560,8 +548,7 @@ fun elements(): List<GenericFunction> {
return last
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty())
throw NoSuchElementException("Collection is empty.")
@@ -600,8 +587,7 @@ fun elements(): List<GenericFunction> {
return last
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"""
return if (isEmpty()) null else this[length - 1]
"""
@@ -616,8 +602,7 @@ fun elements(): List<GenericFunction> {
templates add f("last(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> """Returns the last ${f.element} matching the given [predicate].
@throws [NoSuchElementException] if no such ${f.element} is found.""" }
returns("T")
@@ -642,7 +627,7 @@ fun elements(): List<GenericFunction> {
"""
}
body(CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects, Lists) {
body(CharSequences, ArraysOfPrimitives, ArraysOfObjects, Lists) {
"""
for (index in this.indices.reversed()) {
val element = this[index]
@@ -655,8 +640,7 @@ fun elements(): List<GenericFunction> {
templates add f("lastOrNull(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns the last ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." }
returns("T?")
body { f ->
@@ -677,7 +661,7 @@ fun elements(): List<GenericFunction> {
"""
}
body(CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects, Lists) {
body(CharSequences, ArraysOfPrimitives, ArraysOfObjects, Lists) {
"""
for (index in this.indices.reversed()) {
val element = this[index]
@@ -690,8 +674,7 @@ fun elements(): List<GenericFunction> {
templates add f("findLast(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(Lists, CharSequences, Strings)
include(Lists, CharSequences)
doc { f -> "Returns the last ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." }
returns("T?")
body { "return lastOrNull(predicate)"}
@@ -731,8 +714,7 @@ fun elements(): List<GenericFunction> {
return single
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"""
return when (length) {
0 -> throw NoSuchElementException("Collection is empty.")
@@ -782,8 +764,7 @@ fun elements(): List<GenericFunction> {
return single
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"""
return if (length == 1) this[0] else null
"""
@@ -797,8 +778,7 @@ fun elements(): List<GenericFunction> {
templates add f("single(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns the single ${f.element} matching the given [predicate], or throws exception if there is no or more than one matching ${f.element}." }
returns("T")
body {
@@ -820,8 +800,7 @@ fun elements(): List<GenericFunction> {
templates add f("singleOrNull(predicate: (T) -> Boolean)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns the single ${f.element} matching the given [predicate], or `null` if ${f.element} was not found or more than one ${f.element} was found." }
returns("T?")
body {
@@ -384,8 +384,7 @@ fun filtering(): List<GenericFunction> {
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"""
for (index in 0..length - 1) {
val element = get(index)
@@ -480,9 +479,8 @@ fun filtering(): List<GenericFunction> {
"""
}
deprecate(Strings) { forBinaryCompatibility }
doc(CharSequences) { "Appends all characters not matching the given [predicate] to the given [destination]." }
body(CharSequences, Strings) {
body(CharSequences) {
"""
for (element in this) if (!predicate(element)) destination.append(element)
return destination
@@ -556,8 +556,7 @@ fun generators(): List<GenericFunction> {
}
templates add f("zip(other: CharSequence, transform: (Char, Char) -> V)") {
deprecate(Strings) { forBinaryCompatibility }
only(CharSequences, Strings)
only(CharSequences)
doc {
"""
Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence.
@@ -597,19 +596,6 @@ fun generators(): List<GenericFunction> {
}
}
templates add f("zip(other: String)") {
infix(true)
deprecate(Strings) { forBinaryCompatibility }
only(CharSequences, Strings)
deprecate { forBinaryCompatibility }
returns("List<Pair<Char, Char>>")
body {
"""
return zip(other) { c1, c2 -> c1 to c2 }
"""
}
}
templates add f("zip(other: CharSequence)") {
infix(true)
only(CharSequences)
@@ -6,8 +6,7 @@ fun mapping(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("withIndex()") {
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns a ${if (f == Sequences) f.mapResult else "lazy [Iterable]"} of [IndexedValue] for each ${f.element} of the original ${f.collection}." }
returns("Iterable<IndexedValue<T>>")
body {
@@ -41,8 +40,7 @@ fun mapping(): List<GenericFunction> {
body(ArraysOfObjects, ArraysOfPrimitives) {
"return mapIndexedTo(ArrayList<R>(size), transform)"
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"return mapIndexedTo(ArrayList<R>(length), transform)"
}
inline(false, Sequences)
@@ -69,8 +67,7 @@ fun mapping(): List<GenericFunction> {
body(ArraysOfObjects, ArraysOfPrimitives, Maps) {
"return mapTo(ArrayList<R>(size), transform)"
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"return mapTo(ArrayList<R>(length), transform)"
}
@@ -149,8 +146,7 @@ fun mapping(): List<GenericFunction> {
return destination
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("mapIndexedTo(destination: C, transform: (Int, T) -> R)") {
@@ -174,9 +170,8 @@ fun mapping(): List<GenericFunction> {
return destination
"""
}
deprecate(Strings) { forBinaryCompatibility }
deprecate(Maps) { Deprecation("Use entries.mapIndexedTo instead.", replaceWith = "this.entries.mapIndexedTo(destination, transform)") }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("mapNotNullTo(destination: C, transform: (T) -> R?)") {
@@ -231,8 +226,7 @@ fun mapping(): List<GenericFunction> {
body {
"return flatMapTo(ArrayList<R>(), transform)"
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("flatMap(transform: (T) -> Sequence<R>)") {
@@ -261,8 +255,7 @@ fun mapping(): List<GenericFunction> {
return destination
"""
}
deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings)
include(Maps, CharSequences)
}
templates add f("flatMapTo(destination: C, transform: (T) -> Sequence<R>)") {
@@ -287,8 +280,7 @@ fun mapping(): List<GenericFunction> {
templates add f("groupBy(selector: (T) -> K)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns a map of the ${f.element.pluralize()} in original ${f.collection} grouped by the key returned by the given [selector] function." }
typeParam("K")
returns("Map<K, List<T>>")
@@ -298,8 +290,7 @@ fun mapping(): List<GenericFunction> {
templates add f("groupByTo(map: MutableMap<K, MutableList<T>>, selector: (T) -> K)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
typeParam("K")
doc { f -> "Appends ${f.element.pluralize()} from original ${f.collection} grouped by the key returned by the given [selector] function to the given [map]." }
returns("Map<K, MutableList<T>>")
@@ -47,8 +47,7 @@ fun sequences(): List<GenericFunction> {
// TODO: Drop special case
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"""
if (this is String && isEmpty()) return emptySequence()
return object : Sequence<T> {
@@ -6,8 +6,7 @@ fun snapshots(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("toCollection(destination: C)") {
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Appends all ${f.element.pluralize()} to the given [destination] collection." }
returns("C")
typeParam("C : MutableCollection<in T>")
@@ -26,8 +25,7 @@ fun snapshots(): List<GenericFunction> {
returns("Set<T>")
body { "return toCollection(LinkedHashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
body(Sequences) { "return toCollection(LinkedHashSet<T>())" }
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) { "return toCollection(LinkedHashSet<T>(mapCapacity(length)))" }
body(CharSequences) { "return toCollection(LinkedHashSet<T>(mapCapacity(length)))" }
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(LinkedHashSet<T>(mapCapacity(size)))" }
}
@@ -36,14 +34,12 @@ fun snapshots(): List<GenericFunction> {
returns("HashSet<T>")
body { "return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
body(Sequences) { "return toCollection(HashSet<T>())" }
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) { "return toCollection(HashSet<T>(mapCapacity(length)))" }
body(CharSequences) { "return toCollection(HashSet<T>(mapCapacity(length)))" }
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(HashSet<T>(mapCapacity(size)))" }
}
templates add f("toSortedSet()") {
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
typeParam("T: Comparable<T>")
doc { f -> "Returns a [SortedSet] of all ${f.element.pluralize()}." }
returns("SortedSet<T>")
@@ -76,8 +72,7 @@ fun snapshots(): List<GenericFunction> {
"""
}
body(Collections) { "return ArrayList(this)" }
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) { "return toCollection(ArrayList<T>(length))" }
body(CharSequences) { "return toCollection(ArrayList<T>(length))" }
body(ArraysOfObjects) { "return ArrayList(this.asCollection())" }
body(ArraysOfPrimitives) {
"""
@@ -103,23 +98,12 @@ fun snapshots(): List<GenericFunction> {
}
templates add f("toList()") {
deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings)
include(CharSequences)
doc { f -> "Returns a [List] containing all ${f.element.pluralize()}." }
returns("List<T>")
body { "return this.toArrayList()" }
}
templates add f("toMap(selector: (T) -> K)") {
inline(true)
deprecate(Strings) { forBinaryCompatibility }
body(Strings) { "return toMapBy(selector)" }
include(CharSequences, Strings)
typeParam("K")
returns("Map<K, T>")
deprecate(Deprecation("Use toMapBy instead.", replaceWith = "toMapBy(selector)", level = DeprecationLevel.HIDDEN))
}
templates add f("toMap(transform: (T) -> Pair<K, V>)") {
inline(true)
include(CharSequences)
@@ -210,8 +194,7 @@ fun snapshots(): List<GenericFunction> {
return result
"""
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
body(CharSequences) {
"""
val capacity = (length/.75f) + 1
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
@@ -246,9 +229,6 @@ fun snapshots(): List<GenericFunction> {
}
returns("Map<K, V>")
deprecate(Deprecation("Use toMapBy instead.", "toMapBy(selector, transform)"))
deprecate(Strings) { forBinaryCompatibility }
body(Strings) { "return toMapBy(selector, transform)"}
}
templates add f("toMapBy(selector: (T) -> K, transform: (T) -> V)") {
@@ -55,17 +55,6 @@ fun strings(): List<GenericFunction> {
}
}
templates add f("joinTo(buffer: A, separator: String = \", \", prefix: String = \"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\", transform: ((T) -> String)? = null)") {
deprecate { forBinaryCompatibility }
typeParam("A : Appendable")
returns { "A" }
body {
"""
return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform)
"""
}
}
templates add f("joinToString(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null)") {
doc {
"""
@@ -85,15 +74,5 @@ fun strings(): List<GenericFunction> {
}
}
templates add f("joinToString(separator: String = \", \", prefix: String = \"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\", transform: ((T) -> String)? = null)") {
deprecate { forBinaryCompatibility }
returns("String")
body {
"""
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
"""
}
}
return templates
}