import javax.inject.{Inject, Named}
class MyComponent @Inject() (@Named("states") states: Seq[(String, String)],
@Named("countries") countries: Seq[(String, String)]) {
def stateSize: Int = states.size
def countrySize: Int = countries.size
}
MyModule.scala
import com.google.inject.name.Names.named
import com.google.inject.{AbstractModule, Provider, TypeLiteral}
import scala.collection.immutable.Seq
class MyModule extends AbstractModule {
override def configure(): Unit = {
bind(new TypeLiteral[Seq[(String, String)]]() {})
.annotatedWith(named("states"))
.toInstance(Seq("NY" -> "New York", "NJ" -> "New Jersey"))
bind(new TypeLiteral[Seq[(String, String)]]() {})
.annotatedWith(named("countries"))
.toProvider(new Provider[Seq[(String, String)]] {
override def get() = Seq(("US", "United States"), ("MX", "Mexico"))
})
bind(classOf[MyComponent])
}
}Runner.scalaimport com.google.inject.{Guice, Injector}
object Runner extends App {
val injector:Injector = Guice.createInjector(new MyModule())
val instance: MyComponent = injector.getInstance(classOf[MyComponent])
println(instance)
}
My guess is the mixing of Scala.collection.seq and scala.collection.immutable.seq
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/6af19829-d632-42ff-b534-2a3df8ac63bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.