Status: New
Owner: ----
New issue 290 by phopkins: New BindingTargetVisitor interface needs
wildcard types
http://code.google.com/p/google-guice/issues/detail?id=290
The new BindingTargetVisitor parameters (while otherwise nice and useful)
need wildcard types
to be better-used with generic visitors.
For example, the following code does not compile:
Injector injector = Guice.createInjector();
for (Binding<?> binding : injector.getBindings().values()) {
binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<Object,
Object>() {});
}
In addition, there's an inconsistency in ProviderBinding.
ProviderBinding<T> implements
Binding<Provider<T>>, which means that it must have an
acceptTargetVisitor(BindingTargetVisitor<Provider<T>, V>).
BindingTargetVisitor<Provider<T>>
then has a visitProviderBinding(ProviderBinding<Provider<T>>) method.
ProviderBinding<Provider<T>> implements Binding<Provider<Provider<T>>>, etc.
Attached a patch that adds "? extends" and "? super" in various places
around the Binding
implementations and BindingTargetVisitor. Also changed ProviderBinding to
be:
interface ProviderBinding<T extends Binding<?>> extends Binding<T>
instead of:
interface ProviderBinding<T> extends Binding<Provider<T>>
Note, though, that this means that the #getProvidedKey method now has to
return Key<?>
instead of Key<T>. I think that this is acceptable losses.
Attachments:
wildcard.patch 41.7 KB
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev?hl=en
-~----------~----~----~----~------~----~------~--~---