I have a sealed class which I'd like to send instances of it to another function as an argument. The function should then compare a local instance of sealed class with its argument. How can I achieve this?
sealed class MyState {
data class State1(val someString: String): MyState()
object State2: MyState()
object State3: MyState()
}
The function
fun myFunction(conditionStateClass: Class<MyState>): Boolean {
val newState1 = MyState.State1("foo")
val newState2 = MyState.State2
return newState::class.java == conditionState || newState2::class.java == conditionState // Not possible
}
And I'd like to call the function
myFunction(MyState.State1::class.java)
I know this is wrong. How can I achieve a similar thing?