@Test public void replacesPlaceholder() { String original = "foo ${with.default:defaultValue} bar ${without.default}"; assertThat(PlaceholderResolver.replacePlaceholder(original, "with.default", "replacement"), is("foo replacement bar ${without.default}")); assertThat(PlaceholderResolver.replacePlaceholder(original, "without.default", "replacement"), is("foo ${with.default:defaultValue} bar replacement")); }
@VisibleForTesting public static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue) { return originalString.replaceAll("\\$\\{" + quote(placeholderName) + "(?:\\:[^\\}]*?)?\\}", placeholderValue); }
PlaceholderResolver { @VisibleForTesting public static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue) { return originalString.replaceAll("\\$\\{" + quote(placeholderName) + "(?:\\:[^\\}]*?)?\\}", placeholderValue); } }
PlaceholderResolver { @VisibleForTesting public static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue) { return originalString.replaceAll("\\$\\{" + quote(placeholderName) + "(?:\\:[^\\}]*?)?\\}", placeholderValue); } PlaceholderResolver(ObjectNode rootNode, Map<String, String> externalProperties); }
PlaceholderResolver { @VisibleForTesting public static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue) { return originalString.replaceAll("\\$\\{" + quote(placeholderName) + "(?:\\:[^\\}]*?)?\\}", placeholderValue); } PlaceholderResolver(ObjectNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Properties properties); Collection<UnresolvedPlaceholder> resolve(); @VisibleForTesting static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue); @VisibleForTesting static List<Placeholder> extractPlaceholders(String value); }
PlaceholderResolver { @VisibleForTesting public static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue) { return originalString.replaceAll("\\$\\{" + quote(placeholderName) + "(?:\\:[^\\}]*?)?\\}", placeholderValue); } PlaceholderResolver(ObjectNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Map<String, String> externalProperties); static Collection<UnresolvedPlaceholder> resolvePlaceholders(JsonNode rootNode, Properties properties); Collection<UnresolvedPlaceholder> resolve(); @VisibleForTesting static String replacePlaceholder(String originalString, String placeholderName, String placeholderValue); @VisibleForTesting static List<Placeholder> extractPlaceholders(String value);  }