[
https://issues.apache.org/jira/browse/GROOVY-9817?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-9817.
-----------------------------
> Enhance Closure annotation value (as Closure class) to Arrays
> -------------------------------------------------------------
>
> Key: GROOVY-9817
> URL: https://issues.apache.org/jira/browse/GROOVY-9817
> Project: Groovy
> Issue Type: New Feature
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> The background for this request is annotations in the
> [picocli|https://picocli.info/] library. The annotations API of this library
> allows applications to specify a class or an array of classes to customize
> some behaviour. For example:
> {code:java}
> // current picocli (4.5.2) requires explicit class(es), does not support
> Closures
> @Option(names = "-x",
> completionCandidates = MyCandidates.class,
> converter = [StringConverter.class, MessageDigestConverter.class])
> Map<String, MessageDigest> someOption;
> {code}
> There is [work in progress|https://github.com/remkop/picocli/issues/1258] in
> the picocli library to allow applications to specify closures for such
> classes in the annotations. For example, I would like applications to be able
> to do this:
> {code:java}
> // next version of picocli (4.6.0) aims to support Closures in these
> annotation attributes
> @picocli.CommandLine.Option(names = "-x",
> completionCandidates = {["A", "B", "C"]},
> converter = [ {it}, { str ->
> java.security.MessageDigest.getInstance(str) } ])
> Map<String, java.security.MessageDigest> someOption
> {code}
> With the current version of Groovy (3.0.6), this works for the single-value
> attributes like {{completionCandidates}}, but does not work for attributes
> that take an array of values, like {{converter}}.
> Please add support for arrays in the Closure to Class conversion for
> annotations.
> See also
> [discussion|https://lists.apache.org/thread.html/rcd541adf064adb6839b79c889a5778a80739837a58adce523f86e660%40<dev.groovy.apache.org>]
> on the groovy-dev mailing list.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)