This commit is contained in:
Oleg Vladimirov
2020-06-26 13:28:00 +03:00
parent 7462d32d9d
commit 6eb65908e0

View File

@@ -154,16 +154,18 @@ internal class KotlinJsonAdapter<T>(
/** A simple [Map] that uses parameter indexes instead of sorting or hashing. */ /** A simple [Map] that uses parameter indexes instead of sorting or hashing. */
class IndexedParameterMap( class IndexedParameterMap(
private val parameterKeys: List<KParameter>, private val parameterKeys: List<KParameter>,
private val parameterValues: Array<Any?> private val parameterValues: Array<Any?>
) : AbstractMap<KParameter, Any?>() { ) : AbstractMutableMap<KParameter, Any?>() {
override val entries: Set<Entry<KParameter, Any?>> override fun put(key: KParameter, value: Any?): Any? = null
override val entries: MutableSet<MutableMap.MutableEntry<KParameter, Any?>>
get() { get() {
val allPossibleEntries = parameterKeys.mapIndexed { index, value -> val allPossibleEntries = parameterKeys.mapIndexed { index, value ->
SimpleEntry<KParameter, Any?>(value, parameterValues[index]) SimpleEntry<KParameter, Any?>(value, parameterValues[index])
} }
return allPossibleEntries.filterTo(LinkedHashSet<Entry<KParameter, Any?>>()) { return allPossibleEntries.filterTo(mutableSetOf()) {
it.value !== ABSENT_VALUE it.value !== ABSENT_VALUE
} }
} }