Alex Spence
06/24/2019, 7:52 PMcbruegg
06/24/2019, 7:56 PMinline fun <reified T> MetricFilter(filterId: String, val defaultValue: T?) = MetricFilter(filterId, defaultValue, { it as T })
data class MetricFilter<T>(val filterId: String, val defaultValue: T?, private val caster: (Any?) -> T) {
fun foo(...): ... {
val value: Any? = ...
return MetricFilterValue(this, caster(value))
}
}
cbruegg
06/24/2019, 7:56 PMMetricFilter
with a function that casts the valueAlex Spence
06/24/2019, 8:04 PMAlex Spence
06/24/2019, 8:04 PMAlex Spence
06/24/2019, 8:04 PMAlex Spence
06/24/2019, 8:09 PM