title: Inject a Map of Interface Implementations Keyed by Enum Values
body: <p>I am using Java 8 with a Play framework. My goal is to inject a map whose keys are enum values and values are implementations of a specific interface.  </p>
  
  <p>Here is my enum:</p>
  
  <pre><code>public enum Service {
  
      HTML("html"), TEXT("txt");
  
      private String serviceId;
      Service(String serviceId) { this.serviceId = serviceId; }
  
  }
  </code></pre>
  
  <p>I have <code>Executable</code> interface</p>
  
  <pre><code>public interface Executable { void execute(); }
  </code></pre>
  
  <p>and two classes that implement it:</p>
  
  <pre><code>public class HtmlWorker implements Executable { ... } 
  public class TextWorker implements Executable { ... }
  </code></pre>
  
  <p>I would like to be able to inject  <code>Map&lt;Service, Executable&gt; serviceMap</code> so I can have access to a specific implementation using a <code>Service</code> key:</p>
  
  <pre><code>public class Processor {
  
    @Inject
    Map&lt;Service, Executable&gt; serviceMap;
  
    public void doStuff() {
        Executable htmlService = this.serviceMap.get(Service.HTML);
        Executable textService = this.serviceMap.get(Service.TEXT);
        // do more stuff
    }
  }
  </code></pre>
  
  <p>I added bindings to the module class:</p>
  
  <pre><code>public class AppModule extends AbstractModule {
  
      @Override
      protected void configure() {
          MapBinder&lt;Service, Executable&gt; serviceBinder = MapBinder
            .newMapBinder(binder(), Service.class, Executable.class);
  
          serviceBinder.addBinding(Service.HtmlService).to(HtmlWorker.class);
          serviceBinder.addBinding(Service.TextService).to(TextWorker.class);
  
      }
  </code></pre>
  
  <p>The problem is that <code>serviceMap</code> is never injected and it is always <code>null</code> inside <code>Processor</code>. What am I missing?</p>