Unbound anchors in Guice

The Guice documentation has an Untargetted Binding example like:

bind(MyConcreteClass.class) .annotatedWith(Names.named("foo")) .to(MyConcreteClass.class); 

Can someone explain in plain English what exactly this does and why you would like to do it?

+4
source share
1 answer

Creates a binding of type MyConcreteClass annotated with @Named("foo") using the implementation class MyConcreteClass . You would do this if you wanted to enter this type:

 @Inject public Bar(@Named("foo") MyConcreteClass object) { ... } 
+5
source

Source: https://habr.com/ru/post/1344182/


All Articles