title: Guice: Using @Named to create object
body: <p>Using Guice, if I have</p>
  
  <pre><code>@Inject @Named("light")
  Color light;
  </code></pre>
  
  <p>I can use </p>
  
  <pre><code>bind(Color.class).annotatedWith(Names.named("light"))
      .toInstance(new Color("white"));
  </code></pre>
  
  <p>to bind it to white color if Color constructor only requires color name.</p>
  
  <p>But how can I do it if Color constructor also requires objects which are created by Guice? For example:</p>
  
  <pre><code>@Inject
  public Color(ColorSet colorset, String colorName) {...}
  </code></pre>
  
  <p>where colorset is create at runtime by Guice and in not available in configure(){...}.</p>
  
  <p>I would like to do it without:</p>
  
  <ul>
  <li>creating a class/subclass for each color that I need to inject (like WhiteColor)</li>
  <li>using reflection directly in my code</li>
  <li>changing my classes to use <code>ColorFactoy factory; factory.get("light");</code> instead of <code>@Named("light") Color light;</code></li>
  </ul>