I need to implement an interface which has about 50 methods (external library, I have no control over that).
Instead of having a single class of 1000 lines, I would like to use several classes to implement a few methods around a single feature each, and have a "main" implementing class that delegates to the feature classes.
Can this be done using delegates in kotlin or do I need to implement each method in the main class?
Sample code without using the delegate system:
class Main: ApiInterface {
private val f1 = Feature1()
private val f2 = Feature2()
override fun m1() = f1.m1()
override fun m2() = f1.m2()
override fun m3() = f2.m3()
override fun m4() = f2.m4()
}
class Feature1 {
fun m1() { ... }
fun m2() { ... }
}
class Feature2 {
fun m3() { ... }
fun m4() { ... }
}