https://kotlinlang.org logo
Title
l

Luis Munoz

09/17/2019, 8:50 PM
How do I get this to work without implementing the 100 functions it requires that I won't use?
c

Casey Brooks

09/17/2019, 8:56 PM
If you don’t own that interface, you do have to implement those methods, there’s no way around that. But you could create an abstract class that contains default implementations of all of them, and extending that abstract class instead of the interface directly
l

Luis Munoz

09/17/2019, 9:02 PM
Thank you. Yes I don't own that interface, I was hoping there was some way to avoid the boiler plate but can't think of anything
l

leodeng

09/17/2019, 9:05 PM
m

marstran

09/17/2019, 9:29 PM
Maybe you could use delegation? Requires you to have another StompServerHandler object to delegate to though:
class Handler(delegate: StompServerHandler) : StompServerHandler by delegate {

  // Only override the functions you need.
  override fun handle(serverFrame: ServerFrame) {

  }

}
1
p

pavel

09/17/2019, 10:45 PM
Your IDE might be able to provide default implementations for some of those functions…