Deprecate mapNotNull to change its behavior later.
#KT-4410
This commit is contained in:
@@ -65,9 +65,9 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
|
||||
open class SpecializedProperty<TKey: Any, TValue : Any>() {
|
||||
private val values = HashMap<TKey?, TValue>()
|
||||
|
||||
fun get(key: TKey): TValue? = values.getOrElse(key, { values.getOrElse(null, { null }) })
|
||||
operator fun get(key: TKey): TValue? = values.getOrElse(key, { values.getOrElse(null, { null }) })
|
||||
|
||||
fun set(keys: Collection<TKey>, value: TValue) {
|
||||
operator fun set(keys: Collection<TKey>, value: TValue) {
|
||||
if (keys.isEmpty())
|
||||
values[null] = value;
|
||||
else
|
||||
@@ -77,8 +77,8 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
|
||||
}
|
||||
}
|
||||
|
||||
fun invoke(vararg keys: TKey, valueBuilder: ()-> TValue) = set(keys.asList(), valueBuilder())
|
||||
fun invoke(value: TValue, vararg keys: TKey) = set(keys.asList(), value)
|
||||
operator fun invoke(vararg keys: TKey, valueBuilder: ()-> TValue) = set(keys.asList(), valueBuilder())
|
||||
operator fun invoke(value: TValue, vararg keys: TKey) = set(keys.asList(), value)
|
||||
|
||||
protected open fun onKeySet(key: TKey) {}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,8 @@ fun mapping(): List<GenericFunction> {
|
||||
inline(true)
|
||||
exclude(Strings, ArraysOfPrimitives)
|
||||
doc { "Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection." }
|
||||
deprecate("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().map {} instead.")
|
||||
deprecateReplacement("filterNotNull().map(transform)")
|
||||
typeParam("T : Any")
|
||||
typeParam("R")
|
||||
returns("List<R>")
|
||||
@@ -172,6 +174,8 @@ fun mapping(): List<GenericFunction> {
|
||||
to the given [destination].
|
||||
"""
|
||||
}
|
||||
deprecate("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().mapTo(destination) {} instead.")
|
||||
deprecateReplacement("filterNotNull().mapTo(destination, transform)")
|
||||
typeParam("T : Any")
|
||||
typeParam("R")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
|
||||
Reference in New Issue
Block a user