Data class get all components/properties

You can use Any as well as the specific type. Just add something like:

when (value) {
  is String -> foo()
  is Number -> bar()
  is MyInterface -> next()
}