@Test public void replace_whole() { assertEquals( "new", new Replacement("test", "new").replace("test") ); }
public String replace(String value) { if (value == null) { return null; } else if (isNotBlank(regex) && isNotBlank(replacement)) { Matcher m = Pattern.compile(regex).matcher(value); StringBuffer s = new StringBuffer(); while (m.find()) { m.appendReplacement(s, replacement); } m.appendTail(s); return s.toString(); } else { return value; } }
Replacement { public String replace(String value) { if (value == null) { return null; } else if (isNotBlank(regex) && isNotBlank(replacement)) { Matcher m = Pattern.compile(regex).matcher(value); StringBuffer s = new StringBuffer(); while (m.find()) { m.appendReplacement(s, replacement); } m.appendTail(s); return s.toString(); } else { return value; } } }
Replacement { public String replace(String value) { if (value == null) { return null; } else if (isNotBlank(regex) && isNotBlank(replacement)) { Matcher m = Pattern.compile(regex).matcher(value); StringBuffer s = new StringBuffer(); while (m.find()) { m.appendReplacement(s, replacement); } m.appendTail(s); return s.toString(); } else { return value; } }  }
Replacement { public String replace(String value) { if (value == null) { return null; } else if (isNotBlank(regex) && isNotBlank(replacement)) { Matcher m = Pattern.compile(regex).matcher(value); StringBuffer s = new StringBuffer(); while (m.find()) { m.appendReplacement(s, replacement); } m.appendTail(s); return s.toString(); } else { return value; } }  String replace(String value); static Function<String, String> replacementFn(List<Replacement> replacements); }
Replacement { public String replace(String value) { if (value == null) { return null; } else if (isNotBlank(regex) && isNotBlank(replacement)) { Matcher m = Pattern.compile(regex).matcher(value); StringBuffer s = new StringBuffer(); while (m.find()) { m.appendReplacement(s, replacement); } m.appendTail(s); return s.toString(); } else { return value; } }  String replace(String value); static Function<String, String> replacementFn(List<Replacement> replacements);  }