Implement more general "apply defaults" functionality for host configurations

This commit is contained in:
Ilya Chernikov
2019-09-03 14:46:28 +02:00
parent e3187217ee
commit f350c24846
9 changed files with 71 additions and 29 deletions
@@ -123,6 +123,10 @@ open class PropertiesCollection(protected var properties: Map<Key<*>, Any?> = em
}
}
fun <T> PropertiesCollection.Key<T>.update(body: (T?) -> T?) {
putIfNotNull(body(data[this]?.let { it as T }))
}
// generic for lists
fun <T> PropertiesCollection.Key<in List<T>>.putIfAny(vals: Iterable<T>?) {