Placeholders { public static String merge(Map<Pattern,String> placeholders, String str) { if (Strings.isBlank(str)) { return str; } String replaced = str; for (Map.Entry<Pattern, String> entry : placeholders.entrySet()) { Pattern placeholder = entry.getKey(); String value = entry.getValue(); replaced = placeholder.matcher(replaced).replaceAll(value); } replaced = ESCAPED_OPEN_CURLY_BRACKET.matcher(replaced).replaceAll("{"); replaced = ESCAPED_CLOSE_CURLY_BRACKET.matcher(replaced).replaceAll("}"); return replaced; } private  Placeholders(); static Map<Pattern,String> compile(Map<String,String> placeholders); static String merge(Map<Pattern,String> placeholders, String str);  }
@Test public void mergeShouldReturnSameIfEmpty(){ assertEquals("", Placeholders.merge(null, "")); }