Replace deprecated toMap usages with toMapBy

This commit is contained in:
Ilya Gorbunov
2015-11-30 04:00:31 +03:00
parent f107559a3c
commit ea60ab74a7
11 changed files with 13 additions and 13 deletions
@@ -161,7 +161,7 @@ public enum class CharCategory(public val value: Int, public val code: String) {
public companion object {
private val categoryMap by lazy { CharCategory.values().toMap { it.value } }
private val categoryMap by lazy { CharCategory.values().toMapBy { it.value } }
public fun valueOf(category: Int): CharCategory = categoryMap[category] ?: throw IllegalArgumentException("Category #$category is not defined.")
}
@@ -110,7 +110,7 @@ public enum class CharDirectionality(public val value: Int) {
public companion object {
private val directionalityMap by lazy { CharDirectionality.values().toMap { it.value } }
private val directionalityMap by lazy { CharDirectionality.values().toMapBy { it.value } }
public fun valueOf(directionality: Int): CharDirectionality = directionalityMap[directionality] ?: throw IllegalArgumentException("Directionality #$directionality is not defined.")
}
+2 -2
View File
@@ -170,11 +170,11 @@ fun mapDefinitions(repository: Repository, definitions: Iterable<InterfaceDefini
definitions.filter { "NoInterfaceObject" !in it.extendedAttributes.map { it.call } }.map { generateTrait(repository, it) }
fun generateUnions(ifaces: List<GenerateTraitOrClass>, typedefs: Iterable<TypedefDefinition>): GenerateUnionTypes {
val declaredTypes = ifaces.toMap { it.name }
val declaredTypes = ifaces.toMapBy { it.name }
val anonymousUnionTypes = collectUnionTypes(declaredTypes)
val anonymousUnionTypeTraits = generateUnionTypeTraits(anonymousUnionTypes)
val anonymousUnionsMap = anonymousUnionTypeTraits.toMap { it.name }
val anonymousUnionsMap = anonymousUnionTypeTraits.toMapBy { it.name }
val typedefsToBeGenerated = typedefs.filter { it.types is UnionType }
.map { NamedValue(it.name, it.types as UnionType) }
@@ -227,7 +227,7 @@ private fun Pair<String, String>.betterName() = if (((0..9).map { it.toString()
fun <K, V> List<Pair<K, V>>.toMultiMap(): Map<K, List<V>> = groupBy { it.first }.mapValues { it.value.map { it.second } }
fun Appendable.render(namespace: String, ifaces: List<GenerateTraitOrClass>, unions : GenerateUnionTypes) {
val declaredTypes = ifaces.toMap { it.name }
val declaredTypes = ifaces.toMapBy { it.name }
val allTypes = declaredTypes + unions.anonymousUnionsMap + unions.typedefsMarkersMap
declaredTypes.values.filter { it.namespace == namespace }.forEach {