Reputation: 232
What is the difference between the two while providing binding using Google Guice?
bind(A.class).to(AImpl.class)
bind(A.class).to(Key.get(AImpl.class))
Upvotes: 1
Views: 879
Reputation: 12003
If used the way you do in your example, there is no difference. The first line binds to exactly the class AImpl, the second line binds to a class that matches (isassignable from) A.class. Using the Key wrapper will allow you to bind on generic types and annotated types if you are using more complex use cases.
Upvotes: 2