Class ArgsConversion


  • public final class ArgsConversion
    extends Object
    Utilities to convert Arguments.

    This can be useful when an Argument value is defined as a String, and the expected value has another type.

    Author:
    Damien Carbonne
    • Method Detail

      • convert

        public static Args convert​(Args args,
                                   FormalArgs fargs)
        Converts Arguments to expected types using default converters.

        Result may miss some mandatory formal args.

        Parameters:
        args - The arguments.
        fargs - The description of expected argument types. One matching (name) argument must exist for each argument of args.
        Returns:
        The converted arguments.
        Throws:
        ConversionException - When fargs does not contain matching arguments, or no converter was found or conversion error was raised.
      • convert

        public static Args convert​(Args args,
                                   List<FormalArgs> fargsList)
        Converts Arguments to the first strictly compliant solution.
        Parameters:
        args - The arguments to convert.
        fargsList - A list of formal arguments tuples. The result should match one of them.
        Returns:
        The conversion of args to Arguments that are compliant with one of fargsList.
        Throws:
        ConversionException - When conversion is impossible.
      • convertToStringValues

        public static Args convertToStringValues​(Args args)
        Converts Arguments using default string converters.
        Parameters:
        args - The arguments to convert.
        Returns:
        The conversion of args to an equivalent Arguments composed of strings.
        Throws:
        ConversionException - When conversion is impossible.