title: Enum Switch to handle interface method calls..bad practice?
body: <p>I asked this <a href="https://stackoverflow.com/questions/21372045/using-setter-to-inject-service-into-enum-bad-practice">question</a> but I thought maybe this should be a separate question. Given the following class. Is this the best way to handle interface specific method calls based on a enum type? Thanks</p>
  
  <pre><code>@Component
  public class HelloWorldImpl implements HelloWorld {
  
  private enum MyEnum{
  
  WALK,RUN,JOG,SKIP
  
  }
  
  
  @Autowired
  @Qualifier("walkService")
  private ActivityService walkService;
  
  @Autowired
  @Qualifier("runService")
  private ActivityService runService;
  
  @Override
  public void executeMe(){
   MyEnum myEnum = MyEnum.WALK;
  
    for(MyEnum enum : MyEnum.values()){
      switch(enum){
       case RUN:
          runService.execute();
       case WALK : 
         walkService.execute();
       etc....
      }   
    }
   }
  }
  </code></pre>
  
  <p>I was trying to determine if there was a way I could just use the interface (i.e. ActivityService) to call the execute method instead of being specific to the "MODE" (i.e. switch / if). I was just thinking about what happens if I add a new "MODE" I will have to remember to add a section to this switch statement. Any help is greatly appreciated. </p>
  
  <p>*Update
  This exact pattern is suggested <a href="https://stackoverflow.com/questions/19231875/choose-which-implementation-to-inject-at-runtime-spring">here</a>.</p>