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 88
99import java .util .Locale ;
1010
11+ import static java .lang .Character .charCount ;
12+ import static java .lang .Character .isUpperCase ;
13+ import static java .lang .Character .toUpperCase ;
14+
1115/**
1216 * @author Hardy Ferentschik
1317 */
@@ -102,8 +106,18 @@ public static String nameToMethodName(String name) {
102106 return name .replaceAll ("[\\ s.\\ -!@#%=+/*^&|(){}\\ [\\ ],]" , "_" );
103107 }
104108
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 ();
107121 }
108122
109123 private static boolean startsWithSeveralUpperCaseLetters (String string ) {
You can’t perform that action at this time.
0 commit comments