-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for assisted inject (#59)
* add failing test * add assistedInject * first working version, but need to support multiple injectionPoint * set up test for multiple factory functions * support ability to return multiple injection points from InjectionPointExtractor * bump version and update CHANGELOG * remove unused imports * add shared variable for guice version * add spacing for better readability * remove unused imports * fix CHANGELOG message * remove manual version bump and CHANGELOG update * BREAKING CHANGE: InjectionPointExtractor will now return Iterable<InjectionPoint> Co-authored-by: Harry <85480431+harrylevick@users.noreply.github.com>
- Loading branch information
1 parent
8363802
commit 4c5681d
Showing
8 changed files
with
126 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
prop-all/src/test/java/io/pleo/prop/objects/MyAssistedInjectFactoryImp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.pleo.prop.objects; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.assistedinject.Assisted; | ||
import io.pleo.prop.core.Prop; | ||
|
||
import javax.inject.Named; | ||
|
||
public class MyAssistedInjectFactoryImp { | ||
private final Prop<String> prop; | ||
private final String assistedArg; | ||
|
||
@Inject | ||
public MyAssistedInjectFactoryImp( | ||
@Named("io.pleo.test.prop3") Prop<String> prop, | ||
@Assisted String assistedArg | ||
) { | ||
this.prop = prop; | ||
this.assistedArg = assistedArg; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
prop-all/src/test/java/io/pleo/prop/objects/MyAssistedInjectFactoryImp2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.pleo.prop.objects; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.assistedinject.Assisted; | ||
import io.pleo.prop.core.Prop; | ||
|
||
import javax.inject.Named; | ||
|
||
public class MyAssistedInjectFactoryImp2 { | ||
private final Prop<String> prop; | ||
private final Integer assistedArg; | ||
|
||
@Inject | ||
public MyAssistedInjectFactoryImp2( | ||
@Named("io.pleo.test.prop4") Prop<String> prop, | ||
@Assisted Integer assistedArg | ||
) { | ||
this.prop = prop; | ||
this.assistedArg = assistedArg; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
prop-all/src/test/java/io/pleo/prop/objects/MyAssistedInjectFactoryModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.pleo.prop.objects; | ||
|
||
public interface MyAssistedInjectFactoryModule { | ||
public MyAssistedInjectFactoryImp create(String assistedArg); | ||
} |
6 changes: 6 additions & 0 deletions
6
prop-all/src/test/java/io/pleo/prop/objects/MyAssistedInjectFactoryModuleMultiple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.pleo.prop.objects; | ||
|
||
public interface MyAssistedInjectFactoryModuleMultiple { | ||
public MyAssistedInjectFactoryImp create(String assistedArg); | ||
public MyAssistedInjectFactoryImp2 create(Integer assistedArg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
description = 'Guice integration for Pleo Prop' | ||
|
||
def guiceVersion = '5.0.1' | ||
|
||
dependencies { | ||
api project(':prop-core') | ||
api 'com.google.inject:guice:5.0.1' | ||
api "com.google.inject:guice:$guiceVersion" | ||
api "com.google.inject.extensions:guice-assistedinject:$guiceVersion" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters