So, the question is: How can I simulate such scenario in a language like Java? It would be also helpful to get some background information of how this is solved in other programming languages.
Became Hot Network Question
sum types referes to the same concept as union types.