On Thursday, August 21, 2014 8:35:03 AM UTC+2, Jochen Wiedmann wrote: > > > > Hi, > > > suggest the following field: > > > private @Driver @Inject Seat seat; > > > and the following bindings: > > > pBinder.bind(Seat.class).toClass(DefaultSeat.class); > > pBinder.bind(Seat.class).annotatedWith(Driver.class).toClass(DriversSeat.class); > > > What would be the type of seat? I would hope for a DriversSeat, but that > assumes a priority of bindings, that I am unaware of. Is there something > like that? >
If I'm not mistaken, you'd have an error if you didn't have the second binding: because @Driver is a @BindingAnnotation or @Qualifier, Guice will refuse to inject the field if it hasn't been configured with a binding for "Seat annotated with @Driver" (it won't even inject a Seat instance if Seat is default-instantiable or is annotated with @ImplementedBy or @ProvidedBy). So there's no need for priorities: the "Seat" key is distinct from the "@Driver Seat" one. -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/e38aa7a0-3c25-4ca2-86af-33e0641fe6bf%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
