I need to implement an interface (ResultSet) having hundreds of methods.
For now, I'm going to implement only a subset of these methods, throwing a NotImplementedError for the others.
In Java I found two solutions:
- Create an abstract class
AbstractResultSetimplementingResultSet, declaring all methods to throwNotImplementedError. No hacks, but a lot of boilerplate code. - Use
Proxy.newProxyInstanceto implement all methods together in theInvocationHandler. Less code but also less immediate to use for other coders.
Is there a third option in Kotlin?
In my case, I need to implement a a ResultSet over an IBM dataset (with packed decimals, binary fields, zoned numbers, rows with variable length, etc.) to import it in a SQLServer via SQLServerBulkCopy. I don't know which ResultSet methods are called by this class, so, for now, I'm going to implement only the "most used" methods, logging the calls to unimplemented method.
You can crate an Interface
MyResultSetwhich inherit fromResultSet, and implement all methords to throw NotImplementedError. This is like your first solution in Java, but it's now an interface not a class, and give you more flexibility. Hope help.