Package com.powsybl.tools
Class ToolOptions
- java.lang.Object
-
- com.powsybl.tools.ToolOptions
-
-
Constructor Summary
Constructors Constructor Description ToolOptions(org.apache.commons.cli.CommandLine line, ToolRunningContext context)
ToolOptions(org.apache.commons.cli.CommandLine line, FileSystem fileSystem)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Double>
getDouble(String option)
If exists, return the option value as a double.<E extends Enum<E>>
Optional<E>getEnum(String option, Class<E> clazz)
If exists, return the option value as an enum.Optional<Float>
getFloat(String option)
If exists, return the option value as a float.Optional<Integer>
getInt(String option)
If exists, return the option value as an int.Optional<Path>
getPath(String option)
If exists, return the option value as a file systemPath
.Optional<String>
getValue(String option)
If exists, return the option value as a string.<T> Optional<T>
getValue(String option, Function<String,T> parser)
If exists, return the option value parsed with the provided parser.Optional<List<String>>
getValues(String option)
If exists, return the option value as a list of strings, assuming they were provided as a comma separated list.boolean
hasOption(String option)
Return true if the option is defined.
-
-
-
Constructor Detail
-
ToolOptions
public ToolOptions(org.apache.commons.cli.CommandLine line, FileSystem fileSystem)
-
ToolOptions
public ToolOptions(org.apache.commons.cli.CommandLine line, ToolRunningContext context)
-
-
Method Detail
-
getValue
public Optional<String> getValue(String option)
If exists, return the option value as a string.- Parameters:
option
- The option name- Returns:
- The option value as a string if it exists, otherwise empty.
-
getValue
public <T> Optional<T> getValue(String option, Function<String,T> parser)
If exists, return the option value parsed with the provided parser.- Parameters:
option
- The option nameparser
- A function to transform the value from string to target type.- Returns:
- The option value parsed with the provided parser if it exists, otherwise empty.
-
getInt
public Optional<Integer> getInt(String option)
If exists, return the option value as an int.- Parameters:
option
- The option name- Returns:
- The option value as an int if it exists, otherwise empty.
-
getFloat
public Optional<Float> getFloat(String option)
If exists, return the option value as a float.- Parameters:
option
- The option name- Returns:
- The option value as a float if it exists, otherwise empty.
-
getDouble
public Optional<Double> getDouble(String option)
If exists, return the option value as a double.- Parameters:
option
- The option name- Returns:
- The option value as a double if it exists, otherwise empty.
-
getValues
public Optional<List<String>> getValues(String option)
If exists, return the option value as a list of strings, assuming they were provided as a comma separated list.- Parameters:
option
- The option name- Returns:
- The option value as a list of strings if it exists, otherwise empty.
-
getEnum
public <E extends Enum<E>> Optional<E> getEnum(String option, Class<E> clazz)
If exists, return the option value as an enum.- Parameters:
option
- The option nameclazz
- The enum class- Returns:
- The option value as as an enum. if it exists, otherwise empty.
-
hasOption
public boolean hasOption(String option)
Return true if the option is defined.- Parameters:
option
- The option name- Returns:
true
if the option is defined.
-
-