Class SwitchArg

java.lang.Object
org.jclouds.scriptbuilder.domain.SwitchArg
All Implemented Interfaces:
AcceptsStatementVisitor, Statement

public class SwitchArg extends Object implements Statement, AcceptsStatementVisitor
Statement used in a shell script
  • Field Details

    • OS_TO_SWITCH_PATTERN

      public static final Map<OsFamily,String> OS_TO_SWITCH_PATTERN
    • OS_TO_END_SWITCH_PATTERN

      public static final Map<OsFamily,String> OS_TO_END_SWITCH_PATTERN
    • OS_TO_CASE_PATTERN

      public static final Map<OsFamily,String> OS_TO_CASE_PATTERN
  • Constructor Details

    • SwitchArg

      public SwitchArg(int arg, Map<String,Statement> valueToActions)
      Generates a switch statement based on arg. If its value is found to be a key in valueToActions, the corresponding action is invoked.

      Ex. arg is 1 - the first argument to the script
      and valueToActions is {"start" -> "echo hello", "stop" -> "echo goodbye"}
      the script created will respond accordingly:
      ./script start
      invalid input: '<'invalid input: '<' returns hello
      ./script stop
      invalid input: '<'invalid input: '<' returns goodbye

      Parameters:
      arg - - shell arg to switch on
      valueToActions - - case statements, if the value of the arg matches a key, the corresponding value will be invoked.
  • Method Details