'How to create an Enum class that takes multiple parameters but only uses one of them for comparison initialization?
I want my enum class to take two parameters but only use one of them when comparing which type to initialize. Here I want the id to be passed during initialization as well but not use it to control which type gets created.
enum class ActionEnum(val action: String, val id: String) {
URL("URL") {
override fun start() {
openUrl(id)
}
},
START_FRAGMENT("FRAG") {
override fun start() {
startFragmentWithId(id)
}
},
START_POPUP("POPUP"){
override fun start() {
startPopUpWithMessage(id)
}
};
open fun start() {
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
