thanksforallthefish
12/16/2020, 6:57 AMdata class Entity
that I would like to refactor. in this class there are a lots of method like
fun promote() : Entity {
require(state == States.Initial) { "Cannot promote entity in state $state" }
return copy(state = States.Promoted)
}
fun demote() : Entity = ... same pattern
I would like to turn this into a type system of sort
sealed class Entity
data class Initial : Entity { fun promote() = Promoted(...) }
data class Promoted : Entity { fun demote() = ... }
however there are like a lot and a lot and a lot of usages of current Entity
data class features, especially copy method and equals. how would intellij help me with this refactor? I feel like this is one of those more complex refactor some ide magicians can do in a matter of half a day but would take me forever. I am not worried of taking a long time, since even if there is some magic refactor technique I would not be expert with it and would need to learn it, but I would like to learn it so next time it will be faster.Matteo Mirk
12/16/2020, 11:57 AMMatteo Mirk
12/16/2020, 11:59 AM