picocli
picocli copied to clipboard
API provide IAnnotatedElement getter for all model xxSpec classes
Discussion in #1718 showed that it may be useful if the API for each xxSpec class (CommandSpec, OptionSpec, ArgGroupSpec, etc) had a getAnnotatedElement
method that would return the IAnnotatedElement
for that xxSpec instance.
If the xxSpec instance was created programmatically, not from an annotation, then this method would return null
.
Just to clarify, when having something like:
@RequiredExclusive
@CommandLine.ArgGroup(multiplicity = "1", exclusive = true, validate = false)
GroupOpts group = new GroupOpts()
the IAnnotatedElement
would correspond to the group
field, so groupSpec.getAnnotatedElement().getAnnotation(RequiredExclusive.class)
would return the RequiredExclusive
annotation defined for the group
field.
Also, IAnnotatedElement
doesn't seem to have a method to get all defined annotations.
Just to clarify, when having something like:
@RequiredExclusive @CommandLine.ArgGroup(multiplicity = "1", exclusive = true, validate = false) GroupOpts group = new GroupOpts()
the
IAnnotatedElement
would correspond to thegroup
field, sogroupSpec.getAnnotatedElement().getAnnotation(RequiredExclusive.class)
would return theRequiredExclusive
annotation defined for thegroup
field.
Yes, that matches my understanding.
Also,
IAnnotatedElement
doesn't seem to have a method to get all defined annotations.
Okay, good point, so the IAnnotatedElement
interface may need an additional method like getAnnotations.