Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assisted Injection #14

Closed
johncarl81 opened this issue May 15, 2012 · 1 comment
Closed

Assisted Injection #14

johncarl81 opened this issue May 15, 2012 · 1 comment
Assignees
Milestone

Comments

@johncarl81
Copy link
Owner

Generate the code behind idenfied interfaces to implement Assisted Injection:

public interface Assistant{
     Output buildOutput(Value v);
}

public class Output{
    @Inject
    public Output(@Assissted Value v, SecondInjectedValue v2){...}
}

Generated:

public class AssistantImpl{
     @inject
     public AssistantImpl(SecondInjectedValue v2){...}
     public Output buildOutput(Value v){
        return new Output(v, v2);
     }
}
@ghost ghost assigned johncarl81 May 15, 2012
@johncarl81
Copy link
Owner Author

Assisted Injection is implemented through the Injectors and Binding Qualifiers features:

public interface Assistant{
     Output buildOutput(Value v);
}

public class Output{
    @Inject
    public Output(Value v, SecondInjectedValue v2){...}
}

or:

public interface Assistant{
     Output buildOutput(@Named("stringOne") Thing one, @Named("ThingTwo") Thing two);
}

public class Output{
    @Inject
    public Output(@Named("stringOne") Thing one, @Named("ThingTwo") Thing two, SecondInjectedValue v2){...}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant