|
4 | 4 |
|
5 | 5 | package io.ktor.util |
6 | 6 |
|
| 7 | +import kotlin.jvm.JvmName |
| 8 | + |
7 | 9 | /** |
8 | 10 | * Provides data structure for associating a [String] with a [List] of Strings |
9 | 11 | * |
@@ -113,8 +115,8 @@ public interface StringValuesBuilder { |
113 | 115 | public operator fun get(name: String): String? |
114 | 116 | public fun append(name: String, value: String) |
115 | 117 | public fun appendAll(stringValues: StringValues) |
116 | | - public fun appendMissing(stringValues: StringValues) |
117 | 118 | public fun appendAll(name: String, values: Iterable<String>) |
| 119 | + public fun appendMissing(stringValues: StringValues) |
118 | 120 | public fun appendMissing(name: String, values: Iterable<String>) |
119 | 121 | public fun remove(name: String) |
120 | 122 | public fun removeKeysWithNoEntries() |
@@ -462,6 +464,56 @@ public fun StringValuesBuilder.appendIfNameAndValueAbsent(name: String, value: S |
462 | 464 | append(name, value) |
463 | 465 | } |
464 | 466 |
|
| 467 | +/** |
| 468 | + * Appends multiple key-value pairs to this builder |
| 469 | + * |
| 470 | + * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.StringValuesBuilder.appendAll) |
| 471 | + * |
| 472 | + * @param values the key-value pairs to append |
| 473 | + * @return this builder instance |
| 474 | + */ |
| 475 | +public fun StringValuesBuilder.appendAll(vararg values: Pair<String, String>): StringValuesBuilder = apply { |
| 476 | + values.forEach { (key, value) -> append(key, value) } |
| 477 | +} |
| 478 | + |
| 479 | +/** |
| 480 | + * Appends multiple key-value pairs where values are [Iterable] to this builder |
| 481 | + * |
| 482 | + * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.StringValuesBuilder.appendAll) |
| 483 | + * |
| 484 | + * @param values the key-value pairs to append where values are [Iterable] of strings |
| 485 | + * @return this builder instance |
| 486 | + */ |
| 487 | +@JvmName("appendAllIterable") |
| 488 | +public fun StringValuesBuilder.appendAll(vararg values: Pair<String, Iterable<String>>): StringValuesBuilder = apply { |
| 489 | + values.forEach { (key, value) -> appendAll(key, value) } |
| 490 | +} |
| 491 | + |
| 492 | +/** |
| 493 | + * Appends multiple key-value pairs from a [Map] where values are [Iterable] to this builder |
| 494 | + * |
| 495 | + * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.StringValuesBuilder.appendAll) |
| 496 | + * |
| 497 | + * @param values the map containing key-value pairs to append where values are [Iterable] of strings |
| 498 | + * @return this builder instance |
| 499 | + */ |
| 500 | +@JvmName("appendAllIterable") |
| 501 | +public fun StringValuesBuilder.appendAll(values: Map<String, Iterable<String>>): StringValuesBuilder = apply { |
| 502 | + values.forEach { (key, value) -> appendAll(key, value) } |
| 503 | +} |
| 504 | + |
| 505 | +/** |
| 506 | + * Appends multiple key-value pairs from a [Map] to this builder |
| 507 | + * |
| 508 | + * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.util.StringValuesBuilder.appendAll) |
| 509 | + * |
| 510 | + * @param values the map containing key-value pairs to append |
| 511 | + * @return this builder instance |
| 512 | + */ |
| 513 | +public fun StringValuesBuilder.appendAll(values: Map<String, String>): StringValuesBuilder = apply { |
| 514 | + values.forEach { (key, value) -> append(key, value) } |
| 515 | +} |
| 516 | + |
465 | 517 | private fun entriesEquals(a: Set<Map.Entry<String, List<String>>>, b: Set<Map.Entry<String, List<String>>>): Boolean { |
466 | 518 | return a == b |
467 | 519 | } |
|
0 commit comments