@Test public void toVariable() { String exprHello = VariableTable.toVariable("hello"); VariableTable vars = new VariableTable(); vars.defineVariable("hello", "world"); assertThat(vars.parse(exprHello), is("world")); }
public static String toVariable(String name) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } String expr = "${" + name + "}"; if (VARIABLE.matcher(expr).matches() == false) { throw new IllegalArgumentException(MessageFormat.format( "\"{0}\" is not a valid variable name", name)); } return expr; }
VariableTable { public static String toVariable(String name) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } String expr = "${" + name + "}"; if (VARIABLE.matcher(expr).matches() == false) { throw new IllegalArgumentException(MessageFormat.format( "\"{0}\" is not a valid variable name", name)); } return expr; } }
VariableTable { public static String toVariable(String name) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } String expr = "${" + name + "}"; if (VARIABLE.matcher(expr).matches() == false) { throw new IllegalArgumentException(MessageFormat.format( "\"{0}\" is not a valid variable name", name)); } return expr; } VariableTable();  VariableTable(RedefineStrategy redefineStrategy); }
VariableTable { public static String toVariable(String name) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } String expr = "${" + name + "}"; if (VARIABLE.matcher(expr).matches() == false) { throw new IllegalArgumentException(MessageFormat.format( "\"{0}\" is not a valid variable name", name)); } return expr; } VariableTable();  VariableTable(RedefineStrategy redefineStrategy); static String toVariable(String name); void defineVariable(String name, String replacement); void defineVariables(Map<String, String> variableMap); String toSerialString(); void defineVariables(String variableList); Map<String, String> getVariables(); String parse(String string); String parse(String string, boolean strict); static Set<String> collectVariableNames(String string); @Override String toString(); }
VariableTable { public static String toVariable(String name) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } String expr = "${" + name + "}"; if (VARIABLE.matcher(expr).matches() == false) { throw new IllegalArgumentException(MessageFormat.format( "\"{0}\" is not a valid variable name", name)); } return expr; } VariableTable();  VariableTable(RedefineStrategy redefineStrategy); static String toVariable(String name); void defineVariable(String name, String replacement); void defineVariables(Map<String, String> variableMap); String toSerialString(); void defineVariables(String variableList); Map<String, String> getVariables(); String parse(String string); String parse(String string, boolean strict); static Set<String> collectVariableNames(String string); @Override String toString();  }