title: Java / Refactoring switch case
body: <p>I am trying to refactor the next case:</p>
  
  <pre><code>  class Gen{
      public void startClick(A a, B b, List&lt;C&gt; lstC, SortX sort){
       for (int i=0; i&lt;lstC.size(); i++){
          try{
          // some code with try and catch statement
           switch (sort){
          case SortA:
                newOne(a, b, lstc);
                break;
          case SortB: 
                otherfunction(a);
                break;
          case SortC:
                someotherfunction(lstC, a);
                break;
            }
         }
        } catch (Exception e){ //some code}
       } 
  }
  </code></pre>
  
  <p>I try to create to and case an object, like we see here: <a href="http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism" rel="nofollow">http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism</a></p>
  
  <p>So I create an object: <code>SortOfType</code>, and then for each case I create also an object (<code>SortA</code>, <code>SortB</code>, <code>SortC</code>). The function in <code>SortOfType</code> get the instance of <code>Gen</code>, and so the other Sort objects. What I don't success is to call the sortOfType fron the class Gen. How can I do it? this refactoring is possible here?</p>