Hey guys, is it possible to load configurations wi...
# spring
a
Hey guys, is it possible to load configurations with different implementation based on a property? eg:
Copy code
myConfig:
  myList:
    - type: someType
      propertyA: someValue
      propertyA1: 32
    - type: otherType
      propertyB: otherValue
      propertyB1: abc
Copy code
data class MyConfig(val myList: List<Config>)

interface Config {
    fun doStuff()
}

class SomeType(val propertyA: String, val propertyA1: Int): Config {
    override fun doStuff() {
        println("SomeType $propertyA")
     }
}

class OtherType(val propertyB: String, val propertyB1: String): Config {
    override fun doStuff() {
        println("OtherType $propertyB and $propertyB1")
     }
}
So this way I could do something like
Copy code
class MyService(val myConfig: MyConfig) {
    fun serviceFunction() {
       myConfig.myList.forEach(Config::doStuff)
    }
}