Skip to content

Use type attribute to determine conversion target type instead of field type #197

@remkop

Description

@remkop

This allows fields to be declared as interface or abstract types, and picocli can still convert string command line args to the concrete implementation class specified in the type attribute.

Example:

class App {
    @Option(names = "--num", type = BigDecimal.class) // subclass of field type
    Number[] number; // array type with abstract component class

    @Parameters(type = JapaneseAddress.class) // concrete impl class
    IAddress address; // type declared as interface
}

If the type attribute is not specified, fall back to the array component class or (for single-value fields) the field type.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions