Hi everyone,

In order for assisted injection to work, the factory methods need to be
distinct (either with different names or different signatures):

public interface Factory {
    A1 create1(String name);
    A2 create2(String name);
}

(A1 and A2 have a common super class, in case it matters)

If I add a class A3, I have to modify the interface:

public interface Factory {
    A1 create1(String name);
    A2 create2(String name);
    A3 create3(String name);
}

My question: is it possible to add a new class without modifying the
factory? I tried:

public interface Factory {
    <T> T create(TypeLiteral<T> type, String name);
}

and hoping that calling create(new TypeLiteral<A1>(){}, "foo") would create
an A1, but Guice complains because the factory is not fully specified:
"Factory cannot be used as a key; It is not fully specified."

Any thoughts?

Thanks.

-- 
Cédric

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to