= ...)attribute:
>>>>>>>>
>>>>>>>> class ClosureTest {
>>>>>>>> static class Demo {
>>>>>>>> @picocli.CommandLine.Option(names = "-x",
>>>>>>>> com
]},
>>>>>>> converter = [{ str ->
>>>>>>> java.security.MessageDigest.getInstance(str) }])
>>>>>>> java.security.MessageDigest digest
>>>>>>> }
>>>>>>>
&
converter = [{ str ->
>>>>>> java.security.MessageDigest.getInstance(str) }])
>>>>>> java.security.MessageDigest digest
>>>>>> }
>>>>>>
>>>>>> static void main(String[] args) {
>>>>>> de
> def annotation =
>>>>> Demo.class.getDeclaredField("digest").getAnnotation(picocli.CommandLine.Option)
>>>>> Class ok = annotation.completionCandidates()
>>>>> assert ok != null
>>>>> assert Closure.class.isAssigna
ass[] bad = annotation.converter()
>>>> assert bad != null
>>>> assert bad.length == 1 // this assert fails:
>>>> //Exception in thread "main" Assertion failed:
>>>> //
>>>> //assert bad.l
gt;> assert Closure.class.isAssignableFrom(ok)
>>>> assert ["A", "B", "C"] == ((Closure) ok.getConstructor(Object,
>>>> Object).newInstance(null, null)).call()
>>>>
>>>> Class[] bad = annotation.
s assert fails:
>>> //Exception in thread "main" Assertion failed:
>>> //
>>> //assert bad.length == 1
>>> // | | |
>>> // [] 0 false
>>> //
>>> // at
&g
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:
>>
>
.
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
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
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
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
12 matches
Mail list logo