Power of Enums in Java

It comes sporadically that one has to implement a state machine for a project. Be it a benchmarking tool, or an authentication backend, or a Markov chain generator, it boils down to having a variable in one state, moving to another on certain action. In some of the cases, it might be quite useful to probabilisticaly move among states. There are many ways to implement such behaviour, but I found one really elegant, using Enum in Java.

Protip: Notes in your zsh prompt

I tend to follow good practices. For example, commit certain things in a particular git branch, that should be re-based of another branch that tracks the upstream. However, sometimes I just forget that, especially after not working on that particular code base for a long time, and do a commit in a wrong branch. Git is forgiving, but I wanted more, I wanted to avoid making that mistake in the first place.