File tree Expand file tree Collapse file tree 9 files changed +101
-5
lines changed
inject-generator/src/main/java/io/avaje/inject/generator
inject-test/src/test/java/org/example/inheritprovides Expand file tree Collapse file tree 9 files changed +101
-5
lines changed Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ List<MethodReader> getFactoryMethods() {
92
92
return factoryMethods ;
93
93
}
94
94
95
- List <String > getInterfaces () {
96
- return typeReader .getInterfaces ();
95
+ List <String > getProvides () {
96
+ return typeReader .getProvides ();
97
97
}
98
98
99
99
Set <GenericType > getGenericTypes () {
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ private List<String> asList(String[] content) {
100
100
}
101
101
102
102
void update (BeanReader beanReader ) {
103
- this .provides = beanReader .getInterfaces ();
103
+ this .provides = beanReader .getProvides ();
104
104
this .dependsOn = beanReader .getDependsOn ();
105
105
}
106
106
Original file line number Diff line number Diff line change @@ -72,6 +72,14 @@ List<String> getInterfaceTypes() {
72
72
return interfaceTypes ;
73
73
}
74
74
75
+ List <String > getProvides () {
76
+ List <String > all = new ArrayList <>(extendsTypes .size () + interfaceTypes .size ());
77
+ all .addAll (extendsTypes );
78
+ all .addAll (interfaceTypes );
79
+ all .remove (baseTypeRaw );
80
+ return all ;
81
+ }
82
+
75
83
boolean isCloseable () {
76
84
return closeable ;
77
85
}
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ String getTypesRegister() {
38
38
return typesRegister ;
39
39
}
40
40
41
- List <String > getInterfaces () {
42
- return extendsReader .getInterfaceTypes ();
41
+ List <String > getProvides () {
42
+ return extendsReader .getProvides ();
43
43
}
44
44
45
45
boolean isClosable () {
Original file line number Diff line number Diff line change
1
+ package org .example .inheritprovides ;
2
+
3
+ import jakarta .inject .Inject ;
4
+ import jakarta .inject .Singleton ;
5
+ import java .util .List ;
6
+
7
+ @ Singleton
8
+ public class Application {
9
+
10
+ private final List <Controller > controllers ;
11
+
12
+ @ Inject
13
+ public Application (List <Controller > controllers ) {
14
+ this .controllers = controllers ;
15
+ }
16
+
17
+ public List <Controller > getControllers () {
18
+ return controllers ;
19
+ }
20
+
21
+ }
Original file line number Diff line number Diff line change
1
+ package org .example .inheritprovides ;
2
+
3
+ import io .avaje .inject .BeanScope ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ import java .util .List ;
7
+
8
+ import static org .assertj .core .api .Assertions .assertThat ;
9
+
10
+ class ApplicationTest {
11
+
12
+ @ Test
13
+ void asd () {
14
+ try (BeanScope beanScope = BeanScope .newBuilder ().build ()) {
15
+ Application application = beanScope .get (Application .class );
16
+ List <? extends Controller > controllers = application .getControllers ();
17
+
18
+ assertThat (application ).isNotNull ();
19
+ assertThat (controllers ).hasSize (2 );
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ package org .example .inheritprovides ;
2
+
3
+ import java .util .HashMap ;
4
+ import java .util .Map ;
5
+
6
+ public class Controller {
7
+
8
+ Map <String , String > getContext () {
9
+ return new HashMap <>();
10
+ }
11
+
12
+ }
Original file line number Diff line number Diff line change
1
+ package org .example .inheritprovides ;
2
+
3
+ import jakarta .inject .Singleton ;
4
+ import java .util .Map ;
5
+
6
+ @ Singleton
7
+ public class Controller1 extends Controller {
8
+
9
+ @ Override
10
+ Map <String , String > getContext () {
11
+ Map <String , String > context = super .getContext ();
12
+ context .put ("something" , "1" );
13
+ return context ;
14
+ }
15
+
16
+ }
Original file line number Diff line number Diff line change
1
+ package org .example .inheritprovides ;
2
+
3
+ import jakarta .inject .Singleton ;
4
+
5
+ import java .util .Map ;
6
+
7
+ @ Singleton
8
+ public class Controller2 extends Controller {
9
+
10
+ @ Override
11
+ Map <String , String > getContext () {
12
+ Map <String , String > context = super .getContext ();
13
+ context .put ("something" , "2" );
14
+ return context ;
15
+ }
16
+
17
+ }
You can’t perform that action at this time.
0 commit comments