@Test public void testAppend() { assertEquals("Verification Code.", new StringAppender().append("Verification Code:").toString()); assertEquals("Message.", new StringAppender().append("Message").toString()); assertEquals("Message.", new StringAppender().append("Message.").toString()); assertEquals("Message?", new StringAppender().append("Message?").toString()); assertEquals("Message).", new StringAppender().append("Message)").toString()); assertEquals("m.", new StringAppender().append("m").append(" ").toString()); }
public StringAppender append(final String message) { if(StringUtils.isBlank(message)) { return this; } if(buffer.length() > 0) { buffer.append(" "); } buffer.append(StringUtils.trim(message)); if(buffer.charAt(buffer.length() - 1) == '.') { return this; } if(buffer.charAt(buffer.length() - 1) == ':') { buffer.deleteCharAt(buffer.length() - 1); } if(!Pattern.matches("[.?!]", String.valueOf(buffer.charAt(buffer.length() - 1)))) { buffer.append(suffix); } return this; }
StringAppender { public StringAppender append(final String message) { if(StringUtils.isBlank(message)) { return this; } if(buffer.length() > 0) { buffer.append(" "); } buffer.append(StringUtils.trim(message)); if(buffer.charAt(buffer.length() - 1) == '.') { return this; } if(buffer.charAt(buffer.length() - 1) == ':') { buffer.deleteCharAt(buffer.length() - 1); } if(!Pattern.matches("[.?!]", String.valueOf(buffer.charAt(buffer.length() - 1)))) { buffer.append(suffix); } return this; } }
StringAppender { public StringAppender append(final String message) { if(StringUtils.isBlank(message)) { return this; } if(buffer.length() > 0) { buffer.append(" "); } buffer.append(StringUtils.trim(message)); if(buffer.charAt(buffer.length() - 1) == '.') { return this; } if(buffer.charAt(buffer.length() - 1) == ':') { buffer.deleteCharAt(buffer.length() - 1); } if(!Pattern.matches("[.?!]", String.valueOf(buffer.charAt(buffer.length() - 1)))) { buffer.append(suffix); } return this; } StringAppender();  StringAppender(final char suffix);  StringAppender(final StringBuilder buffer);  StringAppender(final StringBuilder buffer, final char suffix); }
StringAppender { public StringAppender append(final String message) { if(StringUtils.isBlank(message)) { return this; } if(buffer.length() > 0) { buffer.append(" "); } buffer.append(StringUtils.trim(message)); if(buffer.charAt(buffer.length() - 1) == '.') { return this; } if(buffer.charAt(buffer.length() - 1) == ':') { buffer.deleteCharAt(buffer.length() - 1); } if(!Pattern.matches("[.?!]", String.valueOf(buffer.charAt(buffer.length() - 1)))) { buffer.append(suffix); } return this; } StringAppender();  StringAppender(final char suffix);  StringAppender(final StringBuilder buffer);  StringAppender(final StringBuilder buffer, final char suffix); StringAppender append(final String message); @Override String toString(); }
StringAppender { public StringAppender append(final String message) { if(StringUtils.isBlank(message)) { return this; } if(buffer.length() > 0) { buffer.append(" "); } buffer.append(StringUtils.trim(message)); if(buffer.charAt(buffer.length() - 1) == '.') { return this; } if(buffer.charAt(buffer.length() - 1) == ':') { buffer.deleteCharAt(buffer.length() - 1); } if(!Pattern.matches("[.?!]", String.valueOf(buffer.charAt(buffer.length() - 1)))) { buffer.append(suffix); } return this; } StringAppender();  StringAppender(final char suffix);  StringAppender(final StringBuilder buffer);  StringAppender(final StringBuilder buffer, final char suffix); StringAppender append(final String message); @Override String toString();  }