File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
tooling/metamodel-generator/src/main/java/org/hibernate/processor/util Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import java .util .Locale ;
10
10
11
+ import static java .lang .Character .charCount ;
12
+ import static java .lang .Character .isUpperCase ;
13
+ import static java .lang .Character .toUpperCase ;
14
+
11
15
/**
12
16
* @author Hardy Ferentschik
13
17
*/
@@ -102,8 +106,18 @@ public static String nameToMethodName(String name) {
102
106
return name .replaceAll ("[\\ s.\\ -!@#%=+/*^&|(){}\\ [\\ ],]" , "_" );
103
107
}
104
108
105
- public static String getUpperUnderscoreCaseFromLowerCamelCase (String lowerCamelCaseString ){
106
- return lowerCamelCaseString .replaceAll ("(.)(\\ p{Upper})" , "$1_$2" ).toUpperCase (Locale .ROOT );
109
+ public static String getUpperUnderscoreCaseFromLowerCamelCase (String lowerCamelCaseString ) {
110
+ final StringBuilder result = new StringBuilder ();
111
+ int position = 0 ;
112
+ while ( position < lowerCamelCaseString .length () ) {
113
+ final int codePoint = lowerCamelCaseString .codePointAt ( position );
114
+ if ( position >0 && isUpperCase ( codePoint ) ) {
115
+ result .append ('_' );
116
+ }
117
+ result .appendCodePoint ( toUpperCase ( codePoint ) );
118
+ position += charCount ( codePoint );
119
+ }
120
+ return result .toString ();
107
121
}
108
122
109
123
private static boolean startsWithSeveralUpperCaseLetters (String string ) {
You can’t perform that action at this time.
0 commit comments