title: How to avoid switch-case statements in Java
body: <p>I have an enum of TriggerType, where different triggers can be added</p>
  
  <pre><code>public enum TriggerType {
      meta,data,list,toggle
  }
  </code></pre>
  
  <p>These trigger types are used inside different handlers (eg Component, Dashboard etc) to identify which trigger is triggered inside the handler through a switch-case, for eg Code snippet of ComponentHandler using trigger through switch-case is given below</p>
  
  <pre><code>@Override
  public TriggerResultInterface executeTriggerJob(TriggerEventHelper triggerEventHelper) throws TriggerHandlerException {
      switch (triggerEventHelper.getTriggerName()) {
          case meta:
              return getMetaComponentConfig(triggerEventHelper);
          case data:
              return getComponentData(triggerEventHelper);
          default:
              LOGGER.debug(INVALID_TRIGGER_NAME_CONFIGURED);
              throw new TriggerHandlerException(INVALID_TRIGGER_NAME_CONFIGURED);
      }
  
  }
  </code></pre>
  
  <p>Imagine If I want to add a new Trigger, I have to update the enum class which is unavoidable, at the same time I have to update each of my handler classes which that Trigger need to be used, Is this way of design with coding is good or is there any-other better solution that will enhance this code and follows SOLID principles along with a better design. </p>
  
  <p>I would like to stress on saying that this question is not a duplicate of <a href="https://stackoverflow.com/questions/14136721/converting-many-if-else-statements-to-a-cleaner-approach">this</a>. There is only one behavior needed in that situation for each type (eg: convertToMp3). But what my question refers to is my enum type (Trigger Type) is dependent on Handlers which it could possibly be used, so each Trigger Type enum's behavior or implementation will depend on the requirement of the handler it is being used.</p>