Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,19 @@ public static String nameToMethodName(String name) {
public static String getUpperUnderscoreCaseFromLowerCamelCase(String lowerCamelCaseString) {
final StringBuilder result = new StringBuilder();
int position = 0;
boolean wasLowerCase = false;
while ( position < lowerCamelCaseString.length() ) {
final int codePoint = lowerCamelCaseString.codePointAt( position );
if ( position>0 && isUpperCase( codePoint ) ) {
final boolean isUpperCase = isUpperCase( codePoint );
if ( wasLowerCase && isUpperCase ) {
result.append('_');
}
result.appendCodePoint( toUpperCase( codePoint ) );
position += charCount( codePoint );
wasLowerCase = !isUpperCase;
}
if ( result.toString().equals( lowerCamelCaseString ) ) {
result.insert(0, '_');
}
return result.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.uppercase;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;

@Entity
public class Person {
@Id String SSN;
String UserID;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.uppercase;

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

public class UppercaseTest extends CompilationTest {

@Test
@WithClasses(value = Person.class)
public void test() {
System.out.println( getMetaModelSourceAsString( Person.class ) );

assertMetamodelClassGeneratedFor( Person.class );

assertPresenceOfFieldInMetamodelFor( Person.class, "SSN" );
assertPresenceOfFieldInMetamodelFor( Person.class, "_SSN" );
assertPresenceOfFieldInMetamodelFor( Person.class, "UserID" );
assertPresenceOfFieldInMetamodelFor( Person.class, "USER_ID" );
}
}
Loading