How do I perform a Boolean To Enum refactor in IntelliJ IDEA?
For example, convert this:
void changeLights(boolean isOn) {
this.isOn = isOn;
}
changeLights(true);
changeLights(false);
Into this:
enum LightState { ON, OFF }
void changeLights(LightState lightState) {
this.lightState = lightState;
}
changeLights(LightState.ON);
changeLights(LightState.OFF);
I would add a method
Then you can inline this method. Lastly you can "simplify" using the inspection analyse tool to simplify
to
similar for false ->
changeLights(LightState.OFF);