Skip to content

Commit db9c463

Browse files
committed
Only decapitalize if needed
1 parent 1e15dd2 commit db9c463

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,7 @@ private static Method getGetterOrNull(Class containerClass, String propertyName)
513513
// try "get"
514514
if ( methodName.startsWith( "get" ) ) {
515515
final String stemName = methodName.substring( 3 );
516-
final String decapitalizedStemName = Introspector.decapitalize( stemName );
517-
if ( stemName.equals( propertyName ) || decapitalizedStemName.equals( propertyName ) ) {
516+
if ( stemName.equals( propertyName ) || Introspector.decapitalize( stemName ).equals( propertyName ) ) {
518517
verifyNoIsVariantExists( containerClass, propertyName, method, stemName, declaredMethods);
519518
return method;
520519
}
@@ -524,8 +523,7 @@ private static Method getGetterOrNull(Class containerClass, String propertyName)
524523
// if not "get", then try "is"
525524
if ( methodName.startsWith( "is" ) ) {
526525
final String stemName = methodName.substring( 2 );
527-
String decapitalizedStemName = Introspector.decapitalize( stemName );
528-
if ( stemName.equals( propertyName ) || decapitalizedStemName.equals( propertyName ) ) {
526+
if ( stemName.equals( propertyName ) || Introspector.decapitalize( stemName ).equals( propertyName ) ) {
529527
verifyNoGetVariantExists( containerClass, propertyName, method, stemName, declaredMethods);
530528
return method;
531529
}
@@ -678,8 +676,7 @@ private static Method setterOrNull(Class theClass, String propertyName, Class pr
678676
final String methodName = method.getName();
679677
if ( method.getParameterCount() == 1 && methodName.startsWith( "set" ) ) {
680678
final String testOldMethod = methodName.substring( 3 );
681-
final String testStdMethod = Introspector.decapitalize( testOldMethod );
682-
if ( testStdMethod.equals( propertyName ) || testOldMethod.equals( propertyName ) ) {
679+
if (testOldMethod.equals( propertyName ) || Introspector.decapitalize( testOldMethod ).equals( propertyName )) {
683680
potentialSetter = method;
684681
if ( propertyType == null || method.getParameterTypes()[0].equals( propertyType ) ) {
685682
break;
@@ -718,8 +715,7 @@ public static Method findGetterMethodForFieldAccess(Field field, String property
718715
// try "get"
719716
if ( methodName.startsWith( "get" ) ) {
720717
final String stemName = methodName.substring( 3 );
721-
final String decapitalizedStemName = Introspector.decapitalize( stemName );
722-
if ( stemName.equals( propertyName ) || decapitalizedStemName.equals( propertyName ) ) {
718+
if ( stemName.equals( propertyName ) || Introspector.decapitalize( stemName ).equals( propertyName ) ) {
723719
return method;
724720
}
725721

@@ -728,8 +724,7 @@ public static Method findGetterMethodForFieldAccess(Field field, String property
728724
// if not "get", then try "is"
729725
if ( methodName.startsWith( "is" ) ) {
730726
final String stemName = methodName.substring( 2 );
731-
String decapitalizedStemName = Introspector.decapitalize( stemName );
732-
if ( stemName.equals( propertyName ) || decapitalizedStemName.equals( propertyName ) ) {
727+
if ( stemName.equals( propertyName ) || Introspector.decapitalize( stemName ).equals( propertyName ) ) {
733728
return method;
734729
}
735730
}

0 commit comments

Comments
 (0)