Last active
March 5, 2018 14:59
-
-
Save ldaley/5429603 to your computer and use it in GitHub Desktop.
Groovy @DelegatesTo and type tokens.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Agreed. I'll make some experiments around this.