Class AddOptionsFromCommandLine<T>
Object
AddOptionsFromCommandLine<T>
- Type Parameters:
T- the type of the associated entity
- Direct Known Subclasses:
AddInputOptions,AddOutputOptions
Base class for adding options from command-line arguments.
- Author:
- Owen Feehan
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAddOptionsFromCommandLine(CommandLineExtracter extract, T associated) Creates a newAddOptionsFromCommandLineinstance. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidMaybe add options to the arguments from the command-line.protected booleanifOptionWithoutArgument(String optionShort, Consumer<T> consumer) Executesconsumerif an option exists without any argument.protected voidifPresentMultiple(String optionShort, CheckedConsumer<String[], ExperimentExecutionException> consumer) Executesconsumerif one or more options exists with a single argument.protected voidifPresentSingle(String optionShort, CheckedConsumer<String, ExperimentExecutionException> consumer) Executesconsumerif maximally one option exists with a single argument - without passingassociated.protected voidifPresentSingleAssociated(String optionShort, CheckedBiConsumer<T, String, ExperimentExecutionException> consumer) Executesconsumerif maximally one option exists with a single argument - passingassociated.
-
Field Details
-
associated
An associated entity which consumers accept.
-
-
Constructor Details
-
AddOptionsFromCommandLine
Creates a newAddOptionsFromCommandLineinstance.- Parameters:
extract- Extracts options/arguments from the command-line.associated- An associated entity which consumers accept.
-
-
Method Details
-
addOptionsFromCommandLine
Maybe add options to the arguments from the command-line.- Throws:
ExperimentExecutionException- if an error occurs while processing the command-line options
-
ifOptionWithoutArgument
Executesconsumerif 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, throws ExperimentExecutionExceptionExperimentExecutionException> consumer) Executesconsumerif maximally one option exists with a single argument - passingassociated.- 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- ifconsumerthrows it.
-
ifPresentSingle
protected void ifPresentSingle(String optionShort, CheckedConsumer<String, ExperimentExecutionException> consumer) throws ExperimentExecutionExceptionExecutesconsumerif maximally one option exists with a single argument - without passingassociated.- Parameters:
optionShort- name of the option in short form.consumer- called with the extracted single-argument, if the option is present.- Throws:
ExperimentExecutionException- ifconsumerthrows it.
-
ifPresentMultiple
protected void ifPresentMultiple(String optionShort, CheckedConsumer<String[], ExperimentExecutionException> consumer) throws ExperimentExecutionExceptionExecutesconsumerif 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- ifconsumerthrows it.
-