Classes ShinyCoinProvider and RustyCoinProvider both implement Provider<Coin> and each produces a Coin object with slightly different properties.
Another set of two client classes RichPlayer and PoorPlayer need an instance of Coin injected by Guice library automatically.
Now Guice is required to use ShinyCoinProvider in Richplayer and RustyCoinProvider in PoorPlayer classes.
hence simple, bind().toProvider() won’t be sufficient here.
How to bind different providers to different client classes explicitly, where the provided Object is of same type ?
try this:
and annotation Coin field in Richplayer with @Named(“richplayer”) like this: