In the older (1.x.x) versions of Groovy you can add constructors using metaClass.constructor
Example.metaClass.constructor << { String arg0 -> new Example(arg0, "") }
Is there a way to register constructors using the new Groovy 2.0 extension modules?
This seems to work:
Define an extension class as normal for Groovy 2 and just add the constructors in a static initialiser
public class ExampleHelper {
static {
Example.metaClass.constructor << { String arg0 -> new Example(arg0, "") }
}
}