@Test public void replaceToVariableValue() { Properties props = new Properties(); props.setProperty(PropertyParser.KEY_ENABLE_DEFAULT_VALUE, "true"); props.setProperty("key", "value"); props.setProperty("tableName", "members"); props.setProperty("orderColumn", "member_id"); props.setProperty("a:b", "c"); Assertions.assertThat(PropertyParser.parse("${key}", props)).isEqualTo("value"); Assertions.assertThat(PropertyParser.parse("${key:aaaa}", props)).isEqualTo("value"); Assertions.assertThat(PropertyParser.parse("SELECT * FROM ${tableName:users} ORDER BY ${orderColumn:id}", props)).isEqualTo("SELECT * FROM members ORDER BY member_id"); props.setProperty(PropertyParser.KEY_ENABLE_DEFAULT_VALUE, "false"); Assertions.assertThat(PropertyParser.parse("${a:b}", props)).isEqualTo("c"); props.remove(PropertyParser.KEY_ENABLE_DEFAULT_VALUE); Assertions.assertThat(PropertyParser.parse("${a:b}", props)).isEqualTo("c"); }
public static String parse(String string, Properties variables) { VariableTokenHandler handler = new VariableTokenHandler(variables); GenericTokenParser parser = new GenericTokenParser("${", "}", handler); return parser.parse(string); }
PropertyParser { public static String parse(String string, Properties variables) { VariableTokenHandler handler = new VariableTokenHandler(variables); GenericTokenParser parser = new GenericTokenParser("${", "}", handler); return parser.parse(string); } }
PropertyParser { public static String parse(String string, Properties variables) { VariableTokenHandler handler = new VariableTokenHandler(variables); GenericTokenParser parser = new GenericTokenParser("${", "}", handler); return parser.parse(string); } private  PropertyParser(); }
PropertyParser { public static String parse(String string, Properties variables) { VariableTokenHandler handler = new VariableTokenHandler(variables); GenericTokenParser parser = new GenericTokenParser("${", "}", handler); return parser.parse(string); } private  PropertyParser(); static String parse(String string, Properties variables); }
PropertyParser { public static String parse(String string, Properties variables) { VariableTokenHandler handler = new VariableTokenHandler(variables); GenericTokenParser parser = new GenericTokenParser("${", "}", handler); return parser.parse(string); } private  PropertyParser(); static String parse(String string, Properties variables); static final String KEY_ENABLE_DEFAULT_VALUE; static final String KEY_DEFAULT_VALUE_SEPARATOR; }