Skip to content

Commit

Permalink
设置下划线风格替换为驼峰风格的Pattern为StringUtil的静态变量
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngone51 authored and abel533 committed Nov 7, 2017
1 parent 7f0b2f2 commit 3692f7d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/tk/mybatis/mapper/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* Created by liuzh_3nofxnp on 2015/8/26.
*/
public class StringUtil {
private static Pattern UNDERLINE_TO_CAMELHUMP_PATTERN = Pattern.compile("_[a-z]");

/**
* 空
Expand Down Expand Up @@ -104,7 +105,7 @@ public static String camelhumpToUnderline(String str) {
* 将下划线风格替换为驼峰风格
*/
public static String underlineToCamelhump(String str) {
Matcher matcher = Pattern.compile("_[a-z]").matcher(str);
Matcher matcher = UNDERLINE_TO_CAMELHUMP_PATTERN.matcher(str);
StringBuilder builder = new StringBuilder(str);
for (int i = 0; matcher.find(); i++) {
builder.replace(matcher.start() - i, matcher.end() - i, matcher.group().substring(1).toUpperCase());
Expand Down

0 comments on commit 3692f7d

Please sign in to comment.