@DelegatesTo and generics

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

@DelegatesTo and generics

ysb33r


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