Class Switches

java.lang.Object
org.savantbuild.runtime.Switches

public class Switches extends Object
A class that models command-line switches that might have values or not.
  • Field Details

  • Constructor Details

    • Switches

      public Switches()
  • Method Details

    • add

      public void add(String name)
      Adds a switch that has no value (boolean).
      Parameters:
      name - The name of the switch.
    • add

      public void add(String name, String value)
      Adds a switch with the given value.
      Parameters:
      name - The name of the switch.
      value - The value of the switch.
    • has

      public boolean has(String name)
      Returns whether or not the given switch was given by the user. This checks booleans and value switches.
      Parameters:
      name - The name of the switch.
      Returns:
      True if the switch is present (either --foo or --foo=bar).
    • hasValue

      public boolean hasValue(String name, String value)
      Returns whether or not the given switch has the given value.
      Parameters:
      name - The name of the switch.
      value - The value to check for.
      Returns:
      True if the switch has the value.
    • values

      public String[] values(String name)
      Returns the values for the given switch name. If the switch doesn't exist, this returns null.
      Parameters:
      name - The name of the switch.
      Returns:
      The values or null.