Thanks for your reply, Thomas. In particular, I wasn't aware of the
necessity to use @BindingAnnotation. But, lets assume that the annotation
is present on the @Driver class. If so, my example becomes valid. And,
indeed, Guice does create an instance of DriversSeat, rather than
DefaultSeat.

Jochen



On Thu, Aug 21, 2014 at 10:59 AM, Thomas Broyer <[email protected]> wrote:

>
>
> 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 a topic in the
> Google Groups "google-guice" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-guice/bKWvq_HqH0I/unsubscribe.
> To unsubscribe from this group and all its topics, 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
> <https://groups.google.com/d/msgid/google-guice/e38aa7a0-3c25-4ca2-86af-33e0641fe6bf%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Our time is just a point along a line that runs forever with no end.
(Al Stewart, Lord Grenville)

-- 
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/CAF8HOZKhKDcL5wyEOtrtvgnSdeO4RJf%3D3dngx4TTUuJxT8og9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to