Re: Closures in annotations

2020-11-18 Thread Remko Popma
= ...)attribute: >>>>>>>> >>>>>>>> class ClosureTest { >>>>>>>> static class Demo { >>>>>>>> @picocli.CommandLine.Option(names = "-x", >>>>>>>> com

Re: Closures in annotations

2020-11-18 Thread Paul King
]}, >>>>>>> converter = [{ str -> >>>>>>> java.security.MessageDigest.getInstance(str) }]) >>>>>>> java.security.MessageDigest digest >>>>>>> } >>>>>>> &

Re: Closures in annotations

2020-11-18 Thread Remko Popma
converter = [{ str -> >>>>>> java.security.MessageDigest.getInstance(str) }]) >>>>>> java.security.MessageDigest digest >>>>>> } >>>>>> >>>>>> static void main(String[] args) { >>>>>> de

Re: Closures in annotations

2020-11-17 Thread Paul King
> def annotation = >>>>> Demo.class.getDeclaredField("digest").getAnnotation(picocli.CommandLine.Option) >>>>> Class ok = annotation.completionCandidates() >>>>> assert ok != null >>>>> assert Closure.class.isAssigna

Re: Closures in annotations

2020-11-17 Thread Remko Popma
ass[] bad = annotation.converter() >>>> assert bad != null >>>> assert bad.length == 1 // this assert fails: >>>> //Exception in thread "main" Assertion failed: >>>> // >>>> //assert bad.l

Re: Closures in annotations

2020-11-17 Thread Paul King
gt;> assert Closure.class.isAssignableFrom(ok) >>>> assert ["A", "B", "C"] == ((Closure) ok.getConstructor(Object, >>>> Object).newInstance(null, null)).call() >>>> >>>> Class[] bad = annotation.

Re: Closures in annotations

2020-11-16 Thread Remko Popma
s assert fails: >>> //Exception in thread "main" Assertion failed: >>> // >>> //assert bad.length == 1 >>> // | | | >>> // [] 0 false >>> // >>> // at &g

Re: Closures in annotations

2020-11-16 Thread Paul King
020 at 21:16 Remko Popma wrote: > >> PS >> >> The ITypeConverter interface definition is here: >> https://picocli.info/apidocs/picocli/CommandLine.ITypeConverter.html >> >> >> On Mon, Nov 16, 2020 at 21:08 Remko Popma wrote: >> >

RE: Closures in annotations

2020-11-16 Thread Milles, Eric (TR Technology)
. From: Remko Popma Sent: Monday, November 16, 2020 7:02 PM To: Groovy_Developers Subject: Re: Closures in annotations I’m probably overlooking something simple but I’m not seeing it yet. The below code demonstrates the issue when trying to pass a Groovy closure to the @Option(converter

Re: Closures in annotations

2020-11-16 Thread Remko Popma
ClosureTest.main(ClosureTest.groovy:18) } } On Mon, Nov 16, 2020 at 21:16 Remko Popma wrote: > PS > > The ITypeConverter interface definition is here: > https://picocli.info/apidocs/picocli/CommandLine.ITypeConverter.html > > > On Mon, Nov 16, 2020 at 21:08 Remko Po

Re: Closures in annotations

2020-11-16 Thread Remko Popma
PS The ITypeConverter interface definition is here: https://picocli.info/apidocs/picocli/CommandLine.ITypeConverter.html On Mon, Nov 16, 2020 at 21:08 Remko Popma wrote: > Hi all, > > I have a question about passing closures to annotations in Groovy. > To illustrate, consider

Closures in annotations

2020-11-16 Thread Remko Popma
Hi all, I have a question about passing closures to annotations in Groovy. To illustrate, consider the @Option annotation in the picocli library. Relevant attributes are `completionCandidates` and `converter`, defined in Java as follows: @Retention(RetentionPolicy.RUNTIME) @Target