title: Can somebody recommend a java 8 pattern to replace a switch statement?
body: <p>I have following code:</p>
  
  <pre><code> public class A {
      private String type;
      String getType() { return type;}
   }
  </code></pre>
  
  <p>Now  in many code places I have code like this</p>
  
  <pre><code> switch (a.geType()) {
    case "A" : return new Bla();
    case "B" : return new Cop();
   }
  </code></pre>
  
  <p>or somewhere else</p>
  
  <pre><code>switch (a.geType()) {
    case "A" : return new Coda();
    case "B" : return new Man();
   }
  </code></pre>
  
  <p>(Note that I know I should use an  Enumeration in production code). </p>
  
  <p>What I want to achive is that when a new type is added to class A the compiler should flag  all the switch statements that need to be adjusted?</p>
  
  <p>Is there a java idiomatic way to do this?</p>