Class ArgumentTracker

java.lang.Object
org.apache.rat.ui.ArgumentTracker

public final class ArgumentTracker extends Object
Tracks Arg values that are set and their values for conversion from native UI to Apache Commons command line values.
  • Constructor Details

    • ArgumentTracker

      public ArgumentTracker(UIOptionCollection<?> optionCollection)
      The arguments understood by the UI for the current report execution.
      Parameters:
      optionCollection - The AbstractOptionCollection for this UI.
  • Method Details

    • extractKey

      public static String extractKey(org.apache.commons.cli.Option option)
      Extract the core name from the option. This is the Option.getLongOpt() if defined, otherwise the Option.getOpt().
      Parameters:
      option - the commons cli option.
      Returns:
      the common cli based name.
    • extractName

      public static CasedString extractName(org.apache.commons.cli.Option option)
      Generates the CasedString for the specified option.
      Parameters:
      option - the option to extract the name for.
      Returns:
      the CasedString in KEBAB format.
    • args

      public List<String> args()
      Gets the list of arguments prepared for the CLI code to parse.
      Returns:
      the List of arguments for the CLI command line.
    • apply

      public void apply(BiConsumer<String, List<String>> consumer)
      Applies the consumer to each arg and list in turn.
    • setArg

      public void setArg(UIOption<?> key, String value)
      Set a key and value into the argument list. Replaces any existing value.
      Parameters:
      key - the key for the map.
      value - the value to set.
    • setArg

      public void setArg(String trackerKey, String value)
      Set a key and value into the argument list. Replaces any existing value.
      Parameters:
      trackerKey - the key for the map.
      value - the value to set.
    • getArg

      public Optional<List<String>> getArg(String key)
      Get the list of values for a key.
      Parameters:
      key - the key for the map.
      Returns:
      the list of values for the key or null if not set.
    • addArg

      public void addArg(UIOption<?> option, String... value)
      Add values to the key in the argument list. empty values are ignored. If no non-empty values are present no change is made. If the key does not exist, adds it.
      Parameters:
      option - the option to add values for.
      value - the array of values to set.
    • addArg

      public void addArg(String trackerKey, String... value)
      Add values to the key in the argument list. empty values are ignored. If no non-empty values are present no change is made. If the key does not exist, adds it.
      Parameters:
      trackerKey - the key add values for.
      value - the array of values to set.
    • removeArg

      public void removeArg(UIOption<?> option)
      Remove a key from the argument list.
      Parameters:
      option - the option to remove the key for.
    • removeArg

      public void removeArg(String trackerKey)
      Remove a key from the argument list.
      Parameters:
      trackerKey - the key remove.