>However Java doesn’t support type union so you can get into some ugly and verbose situations
Isn't the "sealed interface" described in the OP blog post a type union? Or you mean anonymous unions?
Isn't the "sealed interface" described in the OP blog post a type union? Or you mean anonymous unions?
I haven’t written Java in a while and I can’t remember if you could sometimes fake a type union using a generic type on a method, but if you can, it’s definitely super ugly and would raise eyebrows during any code review.