org.jclouds.scriptbuilder.domain
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
- Author:
- Adrian Cole
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
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
<< returns hello
./script stop
<< returns goodbye
- Parameters:
arg
- - shell arg to switch onvalueToActions
- - case statements, if the value of the arg matches a key, the corresponding value
will be invoked.
render
public String render(OsFamily family)
- Specified by:
render
in interface Statement
functionDependencies
public Iterable<String> functionDependencies(OsFamily family)
- Specified by:
functionDependencies
in interface Statement
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals
in class Object
accept
public void accept(StatementVisitor visitor)
- Specified by:
accept
in interface AcceptsStatementVisitor
Copyright © 2009-2012 jclouds. All Rights Reserved.