Skip to content
Assisted injection for JSR 330.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.buildscript Enable snapshot deployment. Jul 3, 2017
assisted-inject-annotations-dagger2
assisted-inject-annotations
assisted-inject-processor-dagger2 Include factories found in previous processing rounds when generating… Mar 8, 2019
assisted-inject-processor Warn when assisted/provided params are not mixed Nov 25, 2018
assisted-inject-sample-android
gradle
inflation-inject-processor Inflation injection only handles classes, not types Oct 16, 2018
inflation-inject-sample
inflation-inject Rename layout inflater factory Aug 16, 2018
.gitignore
.travis.yml Add new license SHA to license file Mar 6, 2019
CHANGELOG.md Prepare version 0.3.3 Mar 8, 2019
LICENSE.txt
README.md
RELEASING.md Prepare version 0.1.0. Jul 3, 2017
build.gradle Turn R8 on for both samples and validate factory merging Oct 15, 2018
gradle.properties
gradlew
gradlew.bat
settings.gradle
signing.keystore

README.md

Assisted Injection for JSR 330

Manually injected dependencies for your JSR 330 configuration. More about assisted injections in the Guice wiki.

Usage

class MyPresenter {
  @AssistedInject
  MyPresenter(Long foo, @Assisted String bar) {}
  
  @AssistedInject.Factory
  interface Factory {
    MyPresenter create(String bar);
  }
}

This will generate the following:

public final class MyPresenter_AssistedFactory implements MyPresenter.Factory {
  private final Provider<Long> foo;

  @Inject public MyPresenter_AssistedFactory(Provider<Long> foo) {
    this.foo = foo;
  }

  @Override public MyPresenter create(String bar) {
    return new MyPresenter(foo.get(), bar);
  }
}

Usage with Dagger 2

In order to allow Dagger to use the generated factory, define an assisted dagger module anywhere in the same gradle module:

@AssistedModule
@Module(includes = AssistedInject_PresenterModule.class)
abstract class PresenterModule {}

The library will generate the AssistedInject_PresenterModule for us.

Download

compileOnly 'com.squareup.inject:assisted-inject-annotations:0.3.3'
annotationProcessor 'com.squareup.inject:assisted-inject-processor:0.3.3'

With Dagger 2:

compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.3.3'
annotationProcessor 'com.squareup.inject:assisted-inject-processor-dagger2:0.3.3'

License

Copyright 2017 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.