Skip to content

Commit 18b237e

Browse files
committed
Release 0.81.0
- Breaking: Rename config util `plus` to `intoMap` - Make `intoMap` more generic - Add `intoList` util Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 45029fa commit 18b237e

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* ************************************************************************************************
77
*/
88
const val GROUP_ID = "com.salesforce.revoman"
9-
const val VERSION = "0.80.4"
9+
const val VERSION = "0.81.0"
1010
const val ARTIFACT_ID = "revoman"
1111
const val STAGING_PROFILE_ID = "1ea0a23e61ba7d"

src/main/kotlin/com/salesforce/revoman/input/config/KickDef.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.squareup.moshi.JsonAdapter.Factory
1818
import io.vavr.control.Either
1919
import java.io.InputStream
2020
import java.lang.reflect.Type
21+
import java.util.AbstractMap.SimpleEntry
2122
import java.util.Collections.disjoint
2223
import org.immutables.value.Value
2324
import org.immutables.value.Value.Style.ImplementationVisibility.PUBLIC
@@ -99,8 +100,27 @@ internal interface KickDef {
99100
companion object {
100101
@JvmStatic
101102
@SafeVarargs
102-
fun plus(vararg maps: Map<String, out Any?>): Map<String, Any?> =
103-
maps.reduce { acc, map -> acc + map }
103+
fun <K, V> intoMap(vararg items: Any): Map<K, V> where K : Any, V : Any? =
104+
items
105+
.flatMap { item ->
106+
when (item) {
107+
is Map<*, *> -> (item as Map<K, V>).entries
108+
is Pair<*, *> -> listOf(SimpleEntry(item.first as K, item.second as V))
109+
else ->
110+
throw IllegalArgumentException("Expected Map<K,V> or Pair<K,V>, got ${item::class}")
111+
}
112+
}
113+
.associate { it.key to it.value }
114+
115+
@JvmStatic
116+
@SafeVarargs
117+
fun <T> intoList(vararg items: Any): List<T> =
118+
items.flatMap { item ->
119+
when (item) {
120+
is Collection<*> -> item.map { it as T }
121+
else -> listOf(item as T)
122+
}
123+
}
104124
}
105125
}
106126

0 commit comments

Comments
 (0)