Skip to content

Instantly share code, notes, and snippets.

@ldaley
Last active March 5, 2018 14:59
Show Gist options
  • Save ldaley/5429603 to your computer and use it in GitHub Desktop.
Save ldaley/5429603 to your computer and use it in GitHub Desktop.
Groovy @DelegatesTo and type tokens.
Handler<T> handler(@DelegatesTo.Target(asType = true) Class<T> type, @DelegatesTo Closure<?> configurer) {
return new Handler() {
void handle(T object) {
configurer.delegate = object
configure.call(delegate)
}
}
}
@melix
Copy link

melix commented Apr 22, 2013

Agreed. I'll make some experiments around this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment