File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
main/java/org/seasar/doma/internal/util
test/java/org/seasar/doma/internal/util Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 1919
2020/**
2121 * {@link String} のユーティリティクラスです。
22- *
22+ *
2323 * @author taedium
24- *
24+ *
2525 */
2626public final class StringUtil {
2727
2828 /**
2929 * 先頭の文字を大文字に変換します。
30- *
30+ *
3131 * @param text
3232 * 文字列
3333 * @return 変換された文字列。 ただし、{@code text} が {@code null} の場合は {@code null}、
@@ -44,7 +44,7 @@ public static String capitalize(String text) {
4444
4545 /**
4646 * 先頭の文字を小文字に変換します。
47- *
47+ *
4848 * @param text
4949 * 文字列
5050 * @return 変換された文字列。 ただし、{@code text} が {@code null} の場合は {@code null}、
@@ -61,7 +61,7 @@ public static String decapitalize(String text) {
6161
6262 /**
6363 * アンダースコア区切りの文字列をキャメルケースの文字列に変換します。
64- *
64+ *
6565 * @param text
6666 * 文字列
6767 * @return 変換された文字列。 ただし、{@code text} が {@code null} の場合は {@code null}、
@@ -86,7 +86,7 @@ public static String fromSnakeCaseToCamelCase(String text) {
8686
8787 /**
8888 * キャメルケースをアンダースコア区切りの大文字に変換します。
89- *
89+ *
9090 * @param text
9191 * 文字列
9292 * @return 変換された文字列。 ただし、{@code text} が {@code null} の場合は {@code null}、
@@ -104,7 +104,7 @@ public static String fromCamelCaseToSnakeCase(String text) {
104104 buf .mark ();
105105 if (buf .hasRemaining ()) {
106106 char c2 = buf .get ();
107- if (Character .isLowerCase (c ) && Character .isUpperCase (c2 )) {
107+ if (( Character .isLowerCase (c ) || Character . isDigit ( c ) ) && Character .isUpperCase (c2 )) {
108108 result .append ("_" );
109109 }
110110 buf .reset ();
@@ -115,7 +115,7 @@ public static String fromCamelCaseToSnakeCase(String text) {
115115
116116 /**
117117 * 文字列が空白文字だけからなるかどうかを返します。
118- *
118+ *
119119 * @param text
120120 * 文字列
121121 * @return 文字列が空白文字のみを含む場合 {@code true}
Original file line number Diff line number Diff line change 1919
2020/**
2121 * @author taedium
22- *
22+ *
2323 */
2424public class StringUtilTest extends TestCase {
2525
@@ -44,6 +44,7 @@ public void testFromCamelCaseToSnakeCase() throws Exception {
4444 assertEquals ("aaa_bbb_ccc" ,
4545 StringUtil .fromCamelCaseToSnakeCase ("aaaBbbCcc" ));
4646 assertEquals ("abc" , StringUtil .fromCamelCaseToSnakeCase ("abc" ));
47+ assertEquals ("aa1_bbb_ccc" , StringUtil .fromCamelCaseToSnakeCase ("aa1BbbCcc" ));
4748 }
4849
4950 public void testIsWhitespace () throws Exception {
You can’t perform that action at this time.
0 commit comments