The JSON parsing should be parsing the object into...
# announcements
a
The JSON parsing should be parsing the object into an Int, but somewhere I need to cast it from any
c
Maybe this little trick could help you (untested):
Copy code
inline 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))
    }
}
Basically, you provide the
MetricFilter
with a function that casts the value
a
Hmm still getting cannot use T as reified type parameter, use class instead
when I try to call metricFilter
in my builder
Seemed to work around that.