File tree 4 files changed +42
-0
lines changed
main/kotlin/org/jlleitschuh/guice
test/kotlin/org/jlleitschuh/guice
4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ local.properties
80
80
81
81
# # File-based project format:
82
82
* .iws
83
+ * .iml
83
84
84
85
# # Plugin-specific files:
85
86
Original file line number Diff line number Diff line change
1
+ package org.jlleitschuh.guice
2
+
3
+ import com.google.inject.Binder
4
+ import kotlin.reflect.KClass
5
+
6
+ class BinderScope
7
+ internal constructor (private val binder: Binder ) : Binder by binder {
8
+
9
+ /* *
10
+ * See the EDSL examples at [Binder].
11
+ */
12
+ fun <T : Any > bind (klass : KClass <T >) =
13
+ binder.bind(klass::class .java)
14
+ }
Original file line number Diff line number Diff line change
1
+ package org.jlleitschuh.guice
2
+
3
+ import com.google.inject.Binder
4
+ import com.google.inject.Module
5
+
6
+ fun module (configure : BinderScope .() -> Unit ) =
7
+ Module { binder -> BinderScope (binder).configure() }
Original file line number Diff line number Diff line change
1
+ package org.jlleitschuh.guice
2
+
3
+ import com.google.inject.AbstractModule
4
+
5
+ class ModuleTest {
6
+ interface Interface
7
+
8
+ class Implementation : Interface
9
+
10
+ val simpleModule = module {
11
+ bind(key<Interface >()).to(key<Implementation >())
12
+ }
13
+
14
+ val complicated = object : AbstractModule () {
15
+ override fun configure () {
16
+ bind(key<Interface >()).to(key<Implementation >())
17
+ }
18
+
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments