Is it possible in CDI to inject a generic interface implementation?
<p>I'm trying to create a type converter similar to the following:</p>

<pre><code>public interface ConvertToString&lt;T&gt; {
    String convert (T value);
}

public class ConvertLongToString implements ConvertToString&lt;Long&gt; {
    @Override
    public String convert (Long value) {
        return value.toString();
    }
}

public class Foo&lt;T&gt; {
    @Inject
    @Any
    private Instance&lt;ConvertToString&lt;T&gt;&gt; instance;

    private T value;

    public String getValue() {
        return instance.get().convert(value);
    }

    public void setValue(T value) {
        this.value = value;
    }
}
</code></pre>

<p>In this example, I'd want an instance of <code>Foo&lt;Long&gt;</code> to know how to convert the value by injecting the correct converter.</p>

<p>Is this possible using CDI like I've shown or even by iterating the list of instances?</p>

<p>I had in mind to build something similar to the Bean Validation framework where you can create validators of the same annotation for many types (of course you have the <code>@ValidatedBy</code>...)</p>