[LANG-1565] change removeLastFieldSeparator to use endsWith (#550)
* change_removeLastFieldSeparator_to_use_endsWith * stylecheck * revert mis-changes about orders of imports.
This commit is contained in:
parent
9fcd9c86ed
commit
1406f67252
|
@ -437,19 +437,8 @@ public abstract class ToStringStyle implements Serializable {
|
|||
* @since 2.0
|
||||
*/
|
||||
protected void removeLastFieldSeparator(final StringBuffer buffer) {
|
||||
final int len = buffer.length();
|
||||
final int sepLen = fieldSeparator.length();
|
||||
if (sepLen > 0 && len >= sepLen) {
|
||||
boolean match = true;
|
||||
for (int i = 0; i < sepLen; i++) {
|
||||
if (buffer.charAt(len - 1 - i) != fieldSeparator.charAt(sepLen - 1 - i)) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
buffer.setLength(len - sepLen);
|
||||
}
|
||||
if (StringUtils.endsWith(buffer, fieldSeparator)) {
|
||||
buffer.setLength(buffer.length() - fieldSeparator.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue