Search code examples
method-parametersspring-shell

spring shell method parameter List<>


How can I have a spring shell method with a List<> parameter?
is it possible to use List<> as method parameter in Spring_Shell?

as below:

     public void test(
        @CliOption(key = "name", help ="") final String name,
        @CliOption(key = "activities",help ="") final List<String> activitiy){//....... something to do}  

Solution

  • You can definitely do that, but it will be up to you to provide the Converter for it. It would be much better to use a String[] (and optionally convert it to a List<String> as your first instruction in your method body if you really need to), as arrays are supported out of the box (and support conversion and completion, which is impossible with List, because of type erasure)