title: Is it possible to use custom annotations instead of @Named in top of @Provides?
body: <p>Assume we want to <code>@Inject</code> Strings. I create the <code>Module</code>:</p>
  
  <pre><code>public class StringModule extends AbstractModule{
      @Provides
      String black() {
          return "black";
      }
  
      @Provides
      String white() {
          return "white"
      }
  }
  </code></pre>
  
  <p>and now I ask for the injected value:</p>
  
  <pre><code>@Inject
  private String wantWhiteHere;
  </code></pre>
  
  <p>Obviously Guice will throw an error because the binding is ambiguous. I know that i can get <code>white</code> if I use the <code>@Named</code> annotation like that:</p>
  
  <pre><code>public class StringModule extends AbstractModule{
      @Named("black")
      @Provides
      String black() {
          return "black";
      }
  
      @Named("white")
      @Provides
      String white() {
          return "white"
      }
  }
  </code></pre>
  
  <p>and then:</p>
  
  <pre><code>@Named("white")
  @Inject
  private String iGotWhiteHere;
  </code></pre>
  
  <p>But what I want is this:</p>
  
  <pre><code>public class StringModule extends AbstractModule{
      @Black
      @Provides
      String black() {
          return "black";
      }
  
      @White
      @Provides
      String white() {
          return "white"
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>@White
  @Inject
  private String tryingToGetWhiteHere;
  </code></pre>
  
  <p><strong>Is it possible?</strong> When I do it the exception:</p>
  
  <blockquote>
    <p>A binding to java.lang.String was already
    configured...</p>
  </blockquote>
  
  <p>Is there anything anywhere that I can configure to achieve it?</p>
  
  <p>My version of Guice is <a href="https://mvnrepository.com/artifact/com.google.inject/guice/4.2.3" rel="nofollow noreferrer">4.2.3</a></p>