-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: rebuild project due to codegen change (#47)
- Loading branch information
1 parent
f446746
commit fc6c26f
Showing
67 changed files
with
746 additions
and
716 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/core/http/BinaryResponseContent.kt
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.onebusaway.core.http | ||
|
||
import java.util.TreeMap | ||
import org.onebusaway.core.toImmutable | ||
|
||
class Headers private constructor(private val map: Map<String, List<String>>, val size: Int) { | ||
|
||
fun isEmpty(): Boolean = map.isEmpty() | ||
|
||
fun names(): Set<String> = map.keys | ||
|
||
fun values(name: String): List<String> = map[name].orEmpty() | ||
|
||
fun toBuilder(): Builder = Builder().putAll(map) | ||
|
||
companion object { | ||
|
||
fun builder() = Builder() | ||
} | ||
|
||
class Builder { | ||
|
||
private val map: MutableMap<String, MutableList<String>> = | ||
TreeMap(String.CASE_INSENSITIVE_ORDER) | ||
private var size: Int = 0 | ||
|
||
fun put(name: String, value: String) = apply { | ||
map.getOrPut(name) { mutableListOf() }.add(value) | ||
size++ | ||
} | ||
|
||
fun put(name: String, values: Iterable<String>) = apply { values.forEach { put(name, it) } } | ||
|
||
fun putAll(headers: Map<String, Iterable<String>>) = apply { headers.forEach(::put) } | ||
|
||
fun putAll(headers: Headers) = apply { | ||
headers.names().forEach { put(it, headers.values(it)) } | ||
} | ||
|
||
fun replace(name: String, value: String) = apply { | ||
remove(name) | ||
put(name, value) | ||
} | ||
|
||
fun replace(name: String, values: Iterable<String>) = apply { | ||
remove(name) | ||
put(name, values) | ||
} | ||
|
||
fun replaceAll(headers: Map<String, Iterable<String>>) = apply { | ||
headers.forEach(::replace) | ||
} | ||
|
||
fun replaceAll(headers: Headers) = apply { | ||
headers.names().forEach { replace(it, headers.values(it)) } | ||
} | ||
|
||
fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } | ||
|
||
fun removeAll(names: Set<String>) = apply { names.forEach(::remove) } | ||
|
||
fun clear() = apply { | ||
map.clear() | ||
size = 0 | ||
} | ||
|
||
fun build() = | ||
Headers( | ||
map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> | ||
values.toImmutable() | ||
} | ||
.toImmutable(), | ||
size | ||
) | ||
} | ||
|
||
override fun hashCode(): Int = map.hashCode() | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) { | ||
return true | ||
} | ||
|
||
return other is Headers && map == other.map | ||
} | ||
|
||
override fun toString(): String = "Headers{map=$map}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.