Package com.compomics.software.cli
Class CommandParameter
java.lang.Object
com.compomics.software.cli.CommandParameter
public class CommandParameter extends Object
Convenience methods for the validation of command line parameters.
- Author:
- Marc Vaudel, Harald Barsnes
-
Constructor Summary
Constructors Constructor Description CommandParameter()
-
Method Summary
Modifier and Type Method Description static boolean
fileExists(String argType, String arg)
Returns true if the argument can be parsed as a file and the file exists.static boolean
fileExists(String argType, String arg, HashSet<String> formats)
Returns true if the argument can be parsed as a file, the file exists and is in the specified format.static boolean
inDoubleRange(String argType, String arg, double minValue, double maxValue)
Returns true if the input is a double value inside the given range.static boolean
inIntegerRange(String argType, String arg, int minValue, int maxValue)
Returns true if the input is an integer value inside the given range.static boolean
isBooleanInput(String argType, String arg)
Returns true of the input is 0 or 1.static boolean
isDouble(String argType, String arg)
Returns true if the argument can be parsed as a double value.static boolean
isInList(String argType, String arg, String[] supportedInput)
Returns true of the input is in the provided list.static boolean
isInList(String argType, String arg, List<String> supportedInput)
Returns true of the input is in the provided list.static boolean
isInteger(String argType, String arg)
Returns true if the argument can be parsed as an integer value.static boolean
isPositiveDouble(String argType, String arg, boolean allowZero)
Returns true if the argument can be parsed as a positive double value.static boolean
isPositiveInteger(String argType, String arg, boolean allowZero)
Returns true if the argument can be parsed as a positive integer value.static boolean
isSequenceMatchingType(String argType, String arg)
Returns true of the input is in the provided list.
-
Constructor Details
-
CommandParameter
public CommandParameter()
-
-
Method Details
-
inIntegerRange
Returns true if the input is an integer value inside the given range.- Parameters:
argType
- the name of the argumentarg
- the content of the argumentminValue
- the minimum value allowedmaxValue
- the maximum value allowed- Returns:
- true if the input is an integer value inside the given range
-
inDoubleRange
Returns true if the input is a double value inside the given range.- Parameters:
argType
- the name of the argumentarg
- the content of the argumentminValue
- the minimum value allowedmaxValue
- the maximum value allowed- Returns:
- true if the input is a double value inside the given range
-
isInList
Returns true of the input is in the provided list.- Parameters:
argType
- the name of the argumentarg
- the content of the argumentsupportedInput
- the list of supported input- Returns:
- true of the input is in the list
-
isInList
Returns true of the input is in the provided list.- Parameters:
argType
- the name of the argumentarg
- the content of the argumentsupportedInput
- the list of supported input- Returns:
- true of the input is in the list
-
isBooleanInput
Returns true of the input is 0 or 1.- Parameters:
argType
- the name of the argumentarg
- the content of the argument- Returns:
- true of the input is 0 or 1
-
isInteger
Returns true if the argument can be parsed as an integer value.- Parameters:
argType
- the name of the argumentarg
- the content of the argument- Returns:
- true if the argument can be parsed as an integer value
-
isSequenceMatchingType
Returns true of the input is in the provided list.- Parameters:
argType
- the name of the argumentarg
- the content of the argument- Returns:
- true of the input is in the list
-
isDouble
Returns true if the argument can be parsed as a double value.- Parameters:
argType
- the name of the argumentarg
- the content of the argument- Returns:
- true if the argument can be parsed as a double value
-
isPositiveDouble
Returns true if the argument can be parsed as a positive double value.- Parameters:
argType
- the name of the argumentarg
- the content of the argumentallowZero
- if true, zero values are allowed- Returns:
- true if the argument can be parsed as a positive double value
-
isPositiveInteger
Returns true if the argument can be parsed as a positive integer value.- Parameters:
argType
- the name of the argumentarg
- the content of the argumentallowZero
- if true, zero values are allowed- Returns:
- true if the argument can be parsed as a positive integer value
-
fileExists
Returns true if the argument can be parsed as a file and the file exists.- Parameters:
argType
- the name of the argumentarg
- the content of the argument- Returns:
- true if the argument can be parsed as a file and the file exists
-
fileExists
Returns true if the argument can be parsed as a file, the file exists and is in the specified format. The format is case sensitive.- Parameters:
argType
- the name of the argumentarg
- the content of the argumentformats
- The formats allowed as a list, ignored if null- Returns:
- true if the argument can be parsed as a file, the file exists and is in the specified format
-