@Test(expected = IllegalArgumentException.class) public void redefined() { VariableTable parser = new VariableTable(); parser.defineVariable("a", "A"); parser.defineVariable("a", "B"); }
public void defineVariable(String name, String replacement) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } if (replacement == null) { throw new IllegalArgumentException("replacement must not be null"); } if (redefineStrategy != RedefineStrategy.OVERWRITE && variables.containsKey(name)) { if (redefineStrategy == RedefineStrategy.ERROR) { throw new IllegalArgumentException(MessageFormat.format( "variable \"{0}\" is already defined in the variable table: {1}", name, this)); } } else { this.variables.put(name, replacement); } }
VariableTable { public void defineVariable(String name, String replacement) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } if (replacement == null) { throw new IllegalArgumentException("replacement must not be null"); } if (redefineStrategy != RedefineStrategy.OVERWRITE && variables.containsKey(name)) { if (redefineStrategy == RedefineStrategy.ERROR) { throw new IllegalArgumentException(MessageFormat.format( "variable \"{0}\" is already defined in the variable table: {1}", name, this)); } } else { this.variables.put(name, replacement); } } }
VariableTable { public void defineVariable(String name, String replacement) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } if (replacement == null) { throw new IllegalArgumentException("replacement must not be null"); } if (redefineStrategy != RedefineStrategy.OVERWRITE && variables.containsKey(name)) { if (redefineStrategy == RedefineStrategy.ERROR) { throw new IllegalArgumentException(MessageFormat.format( "variable \"{0}\" is already defined in the variable table: {1}", name, this)); } } else { this.variables.put(name, replacement); } } VariableTable();  VariableTable(RedefineStrategy redefineStrategy); }
VariableTable { public void defineVariable(String name, String replacement) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } if (replacement == null) { throw new IllegalArgumentException("replacement must not be null"); } if (redefineStrategy != RedefineStrategy.OVERWRITE && variables.containsKey(name)) { if (redefineStrategy == RedefineStrategy.ERROR) { throw new IllegalArgumentException(MessageFormat.format( "variable \"{0}\" is already defined in the variable table: {1}", name, this)); } } else { this.variables.put(name, replacement); } } 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 void defineVariable(String name, String replacement) { if (name == null) { throw new IllegalArgumentException("name must not be null"); } if (replacement == null) { throw new IllegalArgumentException("replacement must not be null"); } if (redefineStrategy != RedefineStrategy.OVERWRITE && variables.containsKey(name)) { if (redefineStrategy == RedefineStrategy.ERROR) { throw new IllegalArgumentException(MessageFormat.format( "variable \"{0}\" is already defined in the variable table: {1}", name, this)); } } else { this.variables.put(name, replacement); } } 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();  }