@Nullable
needs to be set on both the constructor as well as the factory declaration. We use FactoryModuleBuilder
to declare our Factories. I am pasting the relevant bits of code that work for us
The constructor:
@Inject
public AddressActions(EC2Service ec2Service,
RequestFactory requestFactory,
@Assisted("spiceManager") SpiceManager spiceManager,
@Assisted("parent") Context parent,
@Assisted("publicIp") @Nullable String publicIp) {
The Abstract Factory:
public static interface Factory {
AddressActions create(@Assisted("spiceManager") SpiceManager spiceManager,
@Assisted("parent") Context context,
@Assisted("publicIp") @Nullable String publicIp);
}
The Factory Module Builder:
install(new FactoryModuleBuilder().build(AddressActions.Factory.class));
The call:
AddressActions actions = actionsFactory.create(spiceManager, getSherlockActivity(), null);
Relevant versions:
- Guice:
guice-3.0-no_aop.jar
- AssistedInject:
guice-assistedinject-3.0.jar
- JSR305:
jsr305-1.3.9.jar
-k