Guice multiple annotations
<p>I have an interface called <code>StatsStore</code>. I have 2 implementations of this store. An in-memory and an SQL implementation called <code>InMemoryStatsStore</code> and <code>SqlStatsStore</code>. In order to inject them I've create 2 annotations <code>@InMemoryStore</code> and <code>@SqlStore</code>. the injections are:</p>

<pre><code>bind(StatsStore.class)
    .annotatedWith(InMemoryStore.class)
    .to(InMemoryStatsStore.class);

bind(StatsStore.class)
    .annotatedWith(SqlStore.class)
    .to(SqlStatsStore.class);   
</code></pre>

<p>Now I want to add a new layer of annotation to separate between <code>InMemoryStringStore</code> and <code>InMemoryNumberStore</code> but I can't add more than one annotation to the binding lines e.g. the following does not compile:</p>

<pre><code>bind(StatsStore.class)
    .annotatedWith(InMemoryStore.class)
    .annotatedWith(NumberStoreAnnotation.class) // using named doesn't work as well
    .to(InMemoryNumberStore.class);  
</code></pre>

<p>How can I add more than one annotation without using a single named one which would be quite complicated the more layers I add to it?</p>

<p>The other solution I had in mind is Injecting twice:</p>

<pre><code>bind(StatsStore.class)
    .annotatedWith(InMemoryStore.class)
    .to(InMemoryStatsStore.class);

 bind(InMemoryStatsStore.class)
    .annotatedWith(NumberStoreAnnotation.class)
    .to(InMemoryNumberStore.class);
</code></pre>

<p>Thanks all. </p>