Class AddOptionsFromCommandLine<T>

Object
AddOptionsFromCommandLine<T>
Type Parameters:
T - the type of the associated entity
Direct Known Subclasses:
AddInputOptions, AddOutputOptions

public abstract class AddOptionsFromCommandLine<T> extends Object
Base class for adding options from command-line arguments.
Author:
Owen Feehan
  • Field Details

    • associated

      protected final T associated
      An associated entity which consumers accept.
  • Constructor Details

    • AddOptionsFromCommandLine

      public AddOptionsFromCommandLine(CommandLineExtracter extract, T associated)
      Creates a new AddOptionsFromCommandLine instance.
      Parameters:
      extract - Extracts options/arguments from the command-line.
      associated - An associated entity which consumers accept.
  • Method Details

    • addOptionsFromCommandLine

      public abstract void addOptionsFromCommandLine() throws ExperimentExecutionException
      Maybe add options to the arguments from the command-line.
      Throws:
      ExperimentExecutionException - if an error occurs while processing the command-line options
    • ifOptionWithoutArgument

      protected boolean ifOptionWithoutArgument(String optionShort, Consumer<T> consumer)
      Executes consumer if an option exists without any argument.
      Parameters:
      optionShort - name of the option in short form.
      consumer - called with the associated element, if the option is present.
      Returns:
      true if the option is present, false otherwise.
    • ifPresentSingleAssociated

      protected void ifPresentSingleAssociated(String optionShort, CheckedBiConsumer<T,String,ExperimentExecutionException> consumer) throws ExperimentExecutionException
      Executes consumer if maximally one option exists with a single argument - passing associated.
      Parameters:
      optionShort - name of the option in short form.
      consumer - called with the associated object and the extracted single-argument, if the option is present.
      Throws:
      ExperimentExecutionException - if consumer throws it.
    • ifPresentSingle

      protected void ifPresentSingle(String optionShort, CheckedConsumer<String,ExperimentExecutionException> consumer) throws ExperimentExecutionException
      Executes consumer if maximally one option exists with a single argument - without passing associated.
      Parameters:
      optionShort - name of the option in short form.
      consumer - called with the extracted single-argument, if the option is present.
      Throws:
      ExperimentExecutionException - if consumer throws it.
    • ifPresentMultiple

      protected void ifPresentMultiple(String optionShort, CheckedConsumer<String[],ExperimentExecutionException> consumer) throws ExperimentExecutionException
      Executes consumer if one or more options exists with a single argument.
      Parameters:
      optionShort - name of the option in short form.
      consumer - called with an array of extracted single-arguments, if the option is present.
      Throws:
      ExperimentExecutionException - if consumer throws it.