Class Args

java.lang.Object
dev.nipafx.args.Args

public class Args extends Object
Parses command-line arguments to args records - call parse or one of its overloads (depending on how many args types are involved).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <ARGS_TYPE_1, ARGS_TYPE_2>
    Parsed2<ARGS_TYPE_1,ARGS_TYPE_2>
    parse(String[] argStrings, Class<ARGS_TYPE_1> type1, Class<ARGS_TYPE_2> type2)
    Parses the specified string array to create instances of the specified types.
    static <ARGS_TYPE_1, ARGS_TYPE_2, ARGS_TYPE_3>
    Parsed3<ARGS_TYPE_1,ARGS_TYPE_2,ARGS_TYPE_3>
    parse(String[] argStrings, Class<ARGS_TYPE_1> type1, Class<ARGS_TYPE_2> type2, Class<ARGS_TYPE_3> type3)
    Parses the specified string array to create instances of the specified types.
    static <ARGS_TYPE>
    ARGS_TYPE
    parse(String[] argStrings, Class<ARGS_TYPE> type)
    Parses the specified string array to create an instance of the specified type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Args

      public Args()
  • Method Details

    • parse

      public static <ARGS_TYPE> ARGS_TYPE parse(String[] argStrings, Class<ARGS_TYPE> type) throws ArgsParseException
      Parses the specified string array to create an instance of the specified type.
      Throws:
      ArgsParseException - when the specified argument array can't be correctly parsed
      ArgsDefinitionException - when the specified type is not a valid args type
      IllegalArgumentException - when an illegal argument was passed to parse (it was likely null as other cases are covered by other exceptions)
      IllegalStateException - when an unexpected internal state is encountered - this is likely a bug
    • parse

      public static <ARGS_TYPE_1, ARGS_TYPE_2> Parsed2<ARGS_TYPE_1,ARGS_TYPE_2> parse(String[] argStrings, Class<ARGS_TYPE_1> type1, Class<ARGS_TYPE_2> type2) throws ArgsParseException
      Parses the specified string array to create instances of the specified types.
      Throws:
      ArgsParseException - when the specified argument array can't be correctly parsed
      ArgsDefinitionException - when not all specified types are valid args types
      IllegalArgumentException - when an illegal argument was passed to parse (it was likely null as other cases are covered by other exceptions)
      IllegalStateException - when an unexpected internal state is encountered - this is likely a bug
    • parse

      public static <ARGS_TYPE_1, ARGS_TYPE_2, ARGS_TYPE_3> Parsed3<ARGS_TYPE_1,ARGS_TYPE_2,ARGS_TYPE_3> parse(String[] argStrings, Class<ARGS_TYPE_1> type1, Class<ARGS_TYPE_2> type2, Class<ARGS_TYPE_3> type3) throws ArgsParseException
      Parses the specified string array to create instances of the specified types.
      Throws:
      ArgsParseException - when the specified argument array can't be correctly parsed
      ArgsDefinitionException - when not all specified types are valid args types
      IllegalArgumentException - when an illegal argument was passed to parse (it was likely null as other cases are covered by other exceptions)
      IllegalStateException - when an unexpected internal state is encountered - this is likely a bug