Bit of cleanup suggestions from intellij. (#1168)

This commit is contained in:
Koen De Groote authored and Rob Bygrave committed 2017-10-16 20:16:30 +13:00
1 parent 2c5bf98d0b
commit 4879d44da4
10 files changed
+147 -25

No files matched your search

@@ -1,14 +1,22 @@
package io.ebeaninternal.server.persist;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Utility to improve logging of raw SQL that contains new line characters.
*/
public class TrimLogSql {
/**
* Statically compiled Regex, to avoid having it be compiled every time it is used.
*/
private static final Pattern LINUX_NEW_LINE_REPLACE_PATTERN = Pattern.compile("\n", Pattern.LITERAL);
/**
* Replace new line chars for nicer logging of multi-line sql strings.
*/
public static String trim(String sql) {
return sql.replace("\n", "\\n ");
return LINUX_NEW_LINE_REPLACE_PATTERN.matcher(sql).replaceAll(Matcher.quoteReplacement("\\n "));
}
}