I am working on a project where the input is a map of key-value pairs. Different users can provide different key-value pairs in the input. But the keys are pre-defined and maybe even an Enum. Based on the presence of a key, I need to execute some logic. For example, if the map contains key A, then I need to execute logic x1. If map contains B then execute logic x2, and so on. I was thinking of using the command pattern, where for each key, there is a corresponding command. So if I find A and B in the map, I add both x1 and x2 to my list and once I'm done iterating through all items of the map, I start executing everything in that list.
What do you think of this? How would you approach this problem?