Imho the best you can do with generics is something like

install(new Assist2<Payment, RealPayment>(PaymentFactory.class){});
or

install(new Assist3<SomeClass<Foo, Bar>, SomeOtherClass<Foo, Bar>,
SomeFactory<Foo>(){});

Should be pretty easy to implement this approach. Just look in the
source of TypeLiteral.

If you absolutely need type parameters something like

install(new CustomAssist<Baz>(){}); where

CustomAssist<T> extends
Assist<SomeClass<Foo,T>,SomeOtherClass<Foo,Bar>{...

might be possible but not trivial to implement. But a lot of fun.

Cheers
Alen

On May 10, 7:41 pm, glenviewjeff <[email protected]> wrote:
> If doable, this would sure be more readable than the ten copies of the
> concrete code complete with long-named types duplicated three times in each
> copy.  How would one write a custom utility like you mentioned?  Aren't you
> just re-posing the question implemented as a method chain?  Or does using a
> method chain somehow help solve the problem in a way that I'm missing?
>
>
>
>
>
>
>
> On Thursday, May 10, 2012 11:47:08 AM UTC-5, Alen Vrečko wrote:
>
> > Assisted inject must figure out the real class. It can't figure it out
> > from a parameterized type parameter.
>
> > If you want to save some keystrokes you can go with a custom "utility"
> > like:
>
> > useAssisedInjectFor(Foo.class).using(BarFactory.class);
> > useAssisedInjectFor(Foo.class).generifiedWith(Baz.class).using(BarFactory.c 
> > lass);
>
> > or similar. But I doubt this will give much added value.
>
> > Cheers
> > Alen
>
> > On May 10, 6:08 pm, glenviewjeff <[email protected]> wrote:
> > > I'd like to know how to represent a generic version of the following
> > > binding that won't fail with xxx cannot be used as a key it is not fully
> > > specified
>
> > > install(new FactoryModuleBuilder().
> > >    implement(new TypeLiteral<SomeClass<T,?>>(){},
> > >       new TypeLiteral<SomeOtherClass<T, U>>(){}).
> > >    build(new TypeLiteral<SomeFactory<T>>(){}));
>
> > > It seems that the implement method isn't available with a parameterized
> > > type parameter.
>
> > > Thanks,
> > > Jeff

-- 
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