groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Schalk Cronje <>
Subject @DelegatesTo and generics
Date Thu, 11 Jul 2019 10:42:31 GMT

If I have a generic class and I want to setup a @DelegestTo annotation 
for one of the generic parameters, what is the correct syntax?

For example I want the delegate of the closure to be of type X in this case

     class Foo<X,Y> {
       void bar(String s, @DelegatesTo(X) Closure cfg) { ... }

The above is not the correct syntax I know, but I am not sure what the 
correct one is.

I know something like the following is possible

     public <T> void bar(@DelegatesTo.Target T s, 
@DelegatesTo(genericTypeIndex=0) Closure cfg) {...}

It is the case of referring to generic on the class itself, that I am not sure about.

Schalk W. Cronjé
Twitter / Ello: @ysb33r

View raw message