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 66
77import java .util .Locale ;
88
9+ import static java .lang .Character .charCount ;
10+ import static java .lang .Character .isUpperCase ;
11+ import static java .lang .Character .toUpperCase ;
12+
913/**
1014 * @author Hardy Ferentschik
1115 */
@@ -100,8 +104,18 @@ public static String nameToMethodName(String name) {
100104 return name .replaceAll ("[\\ s.\\ -!@#%=+/*^&|(){}\\ [\\ ],]" , "_" );
101105 }
102106
103- public static String getUpperUnderscoreCaseFromLowerCamelCase (String lowerCamelCaseString ){
104- return lowerCamelCaseString .replaceAll ("(.)(\\ p{Upper})" , "$1_$2" ).toUpperCase (Locale .ROOT );
107+ public static String getUpperUnderscoreCaseFromLowerCamelCase (String lowerCamelCaseString ) {
108+ final StringBuilder result = new StringBuilder ();
109+ int position = 0 ;
110+ while ( position < lowerCamelCaseString .length () ) {
111+ final int codePoint = lowerCamelCaseString .codePointAt ( position );
112+ if ( position >0 && isUpperCase ( codePoint ) ) {
113+ result .append ('_' );
114+ }
115+ result .appendCodePoint ( toUpperCase ( codePoint ) );
116+ position += charCount ( codePoint );
117+ }
118+ return result .toString ();
105119 }
106120
107121 private static boolean startsWithSeveralUpperCaseLetters (String string ) {
You can’t perform that action at this time.
0 commit comments