Package org.savantbuild.runtime
Class Switches
java.lang.Object
org.savantbuild.runtime.Switches
A class that models command-line switches that might have values or not.
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a switch that has no value (boolean).voidAdds a switch with the given value.booleanReturns whether or not the given switch was given by the user.booleanReturns whether or not the given switch has the given value.String[]Returns the values for the given switch name.
-
Field Details
-
booleanSwitches
-
valueSwitches
-
-
Constructor Details
-
Switches
public Switches()
-
-
Method Details
-
add
Adds a switch that has no value (boolean).- Parameters:
name- The name of the switch.
-
add
Adds a switch with the given value.- Parameters:
name- The name of the switch.value- The value of the switch.
-
has
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
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
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.
-