The feature is called AssistedInject, here is an example:
public class PersonLocator() {
@Inject
public PersonLocator(GeneralLocator locator, @Assisted String name) {
...
}
}
To instantiate PersonLocator using the injector you need to create a PersonLocatorFactory:
public interface PersonLocatorFactory {
PersonLocator create(String name);
}
Put a binding into the injector module:
bind(PersonLocatorFactory.class).toProvider(
FactoryProvider.newFactory(PersonLocatorFactory.class, PersonLocator.class));
Then to instantiate PersonLocator use an injected PersonLocatorFactory:
public PersonHunter {
@Inject
public PersonHunter(PersonLocatorFactory personLocatorFactory, String name){
PersonLocator personLocator = personLocatorFactory.create(name);
}
}