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 Details

  • Method Details

    • inIntegerRange

      public static boolean inIntegerRange​(String argType, String arg, int minValue, int maxValue)
      Returns true if the input is an integer value inside the given range.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      minValue - the minimum value allowed
      maxValue - the maximum value allowed
      Returns:
      true if the input is an integer value inside the given range
    • inDoubleRange

      public static boolean inDoubleRange​(String argType, String arg, double minValue, double maxValue)
      Returns true if the input is a double value inside the given range.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      minValue - the minimum value allowed
      maxValue - the maximum value allowed
      Returns:
      true if the input is a double value inside the given range
    • isInList

      public static boolean isInList​(String argType, String arg, String[] supportedInput)
      Returns true of the input is in the provided list.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      supportedInput - the list of supported input
      Returns:
      true of the input is in the list
    • isInList

      public static boolean isInList​(String argType, String arg, List<String> supportedInput)
      Returns true of the input is in the provided list.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      supportedInput - the list of supported input
      Returns:
      true of the input is in the list
    • isBooleanInput

      public static boolean isBooleanInput​(String argType, String arg)
      Returns true of the input is 0 or 1.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      Returns:
      true of the input is 0 or 1
    • isInteger

      public static boolean isInteger​(String argType, String arg)
      Returns true if the argument can be parsed as an integer value.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      Returns:
      true if the argument can be parsed as an integer value
    • isSequenceMatchingType

      public static boolean isSequenceMatchingType​(String argType, String arg)
      Returns true of the input is in the provided list.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      Returns:
      true of the input is in the list
    • isDouble

      public static boolean isDouble​(String argType, String arg)
      Returns true if the argument can be parsed as a double value.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      Returns:
      true if the argument can be parsed as a double value
    • isPositiveDouble

      public static boolean isPositiveDouble​(String argType, String arg, boolean allowZero)
      Returns true if the argument can be parsed as a positive double value.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      allowZero - if true, zero values are allowed
      Returns:
      true if the argument can be parsed as a positive double value
    • isPositiveInteger

      public static boolean isPositiveInteger​(String argType, String arg, boolean allowZero)
      Returns true if the argument can be parsed as a positive integer value.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      allowZero - if true, zero values are allowed
      Returns:
      true if the argument can be parsed as a positive integer value
    • fileExists

      public static boolean fileExists​(String argType, String arg)
      Returns true if the argument can be parsed as a file and the file exists.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      Returns:
      true if the argument can be parsed as a file and the file exists
    • fileExists

      public 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. The format is case sensitive.
      Parameters:
      argType - the name of the argument
      arg - the content of the argument
      formats - 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