fix uppercasing of names in processor to comply with JPA 3.2 spec
This commit is contained in:
parent
73dba9304d
commit
09c627c0b2
|
@ -6,6 +6,10 @@ package org.hibernate.processor.util;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static java.lang.Character.charCount;
|
||||||
|
import static java.lang.Character.isUpperCase;
|
||||||
|
import static java.lang.Character.toUpperCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
*/
|
*/
|
||||||
|
@ -101,7 +105,17 @@ public final class StringUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUpperUnderscoreCaseFromLowerCamelCase(String lowerCamelCaseString) {
|
public static String getUpperUnderscoreCaseFromLowerCamelCase(String lowerCamelCaseString) {
|
||||||
return lowerCamelCaseString.replaceAll("(.)(\\p{Upper})", "$1_$2").toUpperCase(Locale.ROOT);
|
final StringBuilder result = new StringBuilder();
|
||||||
|
int position = 0;
|
||||||
|
while ( position < lowerCamelCaseString.length() ) {
|
||||||
|
final int codePoint = lowerCamelCaseString.codePointAt( position );
|
||||||
|
if ( position>0 && isUpperCase( codePoint ) ) {
|
||||||
|
result.append('_');
|
||||||
|
}
|
||||||
|
result.appendCodePoint( toUpperCase( codePoint ) );
|
||||||
|
position += charCount( codePoint );
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean startsWithSeveralUpperCaseLetters(String string) {
|
private static boolean startsWithSeveralUpperCaseLetters(String string) {
|
||||||
|
|
Loading…
Reference in New Issue