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 newAddOptionsFromCommandLine
instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
Maybe add options to the arguments from the command-line.protected boolean
ifOptionWithoutArgument
(String optionShort, Consumer<T> consumer) Executesconsumer
if an option exists without any argument.protected void
ifPresentMultiple
(String optionShort, CheckedConsumer<String[], ExperimentExecutionException> consumer) Executesconsumer
if one or more options exists with a single argument.protected void
ifPresentSingle
(String optionShort, CheckedConsumer<String, ExperimentExecutionException> consumer) Executesconsumer
if maximally one option exists with a single argument - without passingassociated
.protected void
ifPresentSingleAssociated
(String optionShort, CheckedBiConsumer<T, String, ExperimentExecutionException> consumer) Executesconsumer
if maximally one option exists with a single argument - passingassociated
.
-
Field Details
-
associated
An associated entity which consumers accept.
-
-
Constructor Details
-
AddOptionsFromCommandLine
Creates a newAddOptionsFromCommandLine
instance.- 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
Executesconsumer
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, throws ExperimentExecutionExceptionExperimentExecutionException> consumer) Executesconsumer
if 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
- ifconsumer
throws it.
-
ifPresentSingle
protected void ifPresentSingle(String optionShort, CheckedConsumer<String, ExperimentExecutionException> consumer) throws ExperimentExecutionExceptionExecutesconsumer
if 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
- ifconsumer
throws it.
-
ifPresentMultiple
protected void ifPresentMultiple(String optionShort, CheckedConsumer<String[], ExperimentExecutionException> consumer) throws ExperimentExecutionExceptionExecutesconsumer
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
- ifconsumer
throws it.
-