groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud Estève <arnaud.est...@gmail.com>
Subject Get delegate in an ExtensionModule
Date Fri, 04 Dec 2015 09:16:01 GMT
Hello,

I'm currently playing with extension modules and congrats, it's very fun to
add syntaxic sugar to an existing API.

I was wondering if it was possible to delegate to the "super" method within
an extension module.

For instance, let's imagine I want to overload String's asType() method :

class MyStringExtension {
  static Object asType(String self, Class someClass) {
    if (myClass = SomethingICanHandler.class) {
      // create an object from my string
    } else {
      // Here I'd like to "delegate" to the default String asType() method
    }
  }
}

With metaclass it would be easy, but is it even possible (and does it make
sense ?) to do so with an extension module ?

Thanks a lot :)

Mime
View raw message