Oct 23, 2022
Very elegant solution. But I think you used reflection just to avoid having a simple Factory with if-else statements.
In case of a factory I think it would be fine to use it with if-else statements. In other cases I prefer to do just if checks and early exit when possible.