It seems as tho there are multiple different ways that this could be implemented that all conflict with one another. One way to make this easier tho would be by having a class that implements that interface and takes a list of objects of that interface and then does the delegation (let’s call it SuperWrapper
. Then, in you actual classes, you can just have a constructor parameter or a property which is a list of those interfaces, and then just delegate the interface to the SuperWrapper
. Something kinda like this:
interface Test {
fun doStuff1(arg1: Int, arg2 : String)
fun doStuff2(arg1: Any) : String
}
class TestSuperWrapper(val tests: List<Test>){
fun doStuff1(arg1: Int, arg2: String){
tests.forEach { it.doStuff1(arg1, arg2)}
}
fun doStuff2 (arg1: Any) : String{
return tests.map { it.doStuff2(arg1) }.join(",")
}
}
class MyClass(tests: List<Tests>) : Test by TestSuperWrapper(tests) {
// Other stuff
}