|
Re: Building Commands at Runtime
Same thing- using strings is less compact and is a bit more repetitious. Instead of having a massive if/else/switch complex for the strings, you can just get a fresh instance of the command and pass it along to the addSequential method. If you want to add or remove an option, you only need to edit what you add to the sendablechooser. If you use the sendablechooser in multiple different command groups, you need only one line instead of the whole if/else/switch chain.
The supplier also guarantees that each command group has a unique instance of a command.
*Also imo lambdas and method references are more readable and look more elegant
|