How to get the string instance in guice

Lets say I have binded my strings in guice like this

bind(String.class).annotatedWith(MasterDatabase.class).toInstance("integration");

If I have the handler to injector for this module, how would I get back the value binded through the annotation name? Here I wanted the string value associated with MasterDatabase annotation

Jon Skeet
people
quotationmark

Well you'd normally use constructor injection using the annotation:

@Inject
public SomeType(@MasterDatabase String databaseName)

Or you could explicitly request it from the injector:

String databaseName = injector.getInstance(Key.get(String.class,
                                                   MasterDatabase.class));

people

See more on this question at Stackoverflow