title: Call a specific method based on enum type?
body: <p>Here is an abstract example of my problem: I have a general class (<code>Car</code>) which has a type (<code>brand</code>). All objects should only differ by brand, and based on this brand should be handled differently.</p>
  
  <p>All objects of this class are collected in a List of a Service class. The service should perform a routine on the whole list, which is <em>mostly</em> the same. Just one function call in between should differ.</p>
  
  <p>Based on this type I want to call different methods: At the moment I'm asserting equals for the enum type and call different methods based on the outcome. But this is kind of ugly and I wonder if there are better solutions on this?</p>
  
  <pre><code>class Car {
      public enum Brand {
          BMW, AUDI;
      }
  
      private Brand brand;
  
      specificMeth1();
      specificMeth2();
  }
  
  
  class Service {
  
      List&lt;Car&gt; bmw;
      List&lt;Car&gt; Audi;
  
      processCar() {
          processList(bmw);
          processList(audi);
      }
  
      processList(List&lt;Car&gt; list) {
          for (Car car : list) {
              if (car.getBrand.equals(Brand.BMW)) {
                  specificMeth1();
              } else {
                  specificMeth2();
              }
          }
      }
  }
  </code></pre>