|
15 | 15 | import java.lang.reflect.TypeVariable; |
16 | 16 | import java.lang.reflect.WildcardType; |
17 | 17 | import java.util.Locale; |
| 18 | +import java.util.Objects; |
18 | 19 | import java.util.function.Supplier; |
19 | 20 |
|
20 | 21 | import org.hibernate.AssertionFailure; |
@@ -573,16 +574,15 @@ public static void verifyNoIsVariantExists( |
573 | 574 | Method getMethod, |
574 | 575 | String stemName) { |
575 | 576 | // verify that the Class<?> does not also define a method with the same stem name with 'is' |
576 | | - try { |
577 | | - final Method isMethod = containerClass.getDeclaredMethod( "is" + stemName ); |
578 | | - if ( !Modifier.isStatic( isMethod.getModifiers() ) && isMethod.getAnnotation( Transient.class ) == null ) { |
579 | | - // No such method should throw the caught exception. So if we get here, there was |
580 | | - // such a method. |
581 | | - checkGetAndIsVariants( containerClass, propertyName, getMethod, isMethod ); |
| 577 | + for ( Method declaredMethod : containerClass.getDeclaredMethods() ) { |
| 578 | + if ( declaredMethod.getParameterCount() == 0 |
| 579 | + && !Modifier.isStatic( declaredMethod.getModifiers() ) |
| 580 | + && declaredMethod.getName().startsWith("is") |
| 581 | + && declaredMethod.getName().regionMatches(0, stemName, 0, stemName.length() ) |
| 582 | + && declaredMethod.getAnnotation( Transient.class ) == null ) { |
| 583 | + checkGetAndIsVariants( containerClass, propertyName, getMethod, declaredMethod ); |
582 | 584 | } |
583 | 585 | } |
584 | | - catch (NoSuchMethodException ignore) { |
585 | | - } |
586 | 586 | } |
587 | 587 |
|
588 | 588 |
|
@@ -613,17 +613,15 @@ public static void verifyNoGetVariantExists( |
613 | 613 | Method isMethod, |
614 | 614 | String stemName) { |
615 | 615 | // verify that the Class<?> does not also define a method with the same stem name with 'is' |
616 | | - try { |
617 | | - final Method getMethod = containerClass.getDeclaredMethod( "get" + stemName ); |
618 | | - // No such method should throw the caught exception. So if we get here, there was |
619 | | - // such a method. |
620 | | - if ( !Modifier.isStatic( getMethod.getModifiers() ) |
621 | | - && getMethod.getAnnotation( Transient.class ) == null ) { |
622 | | - checkGetAndIsVariants( containerClass, propertyName, getMethod, isMethod ); |
| 616 | + for ( Method declaredMethod : containerClass.getDeclaredMethods() ) { |
| 617 | + if ( declaredMethod.getParameterCount() == 0 |
| 618 | + && !Modifier.isStatic( declaredMethod.getModifiers() ) |
| 619 | + && declaredMethod.getName().startsWith("is") |
| 620 | + && declaredMethod.getName().regionMatches(0, stemName, 0, stemName.length() ) |
| 621 | + && declaredMethod.getAnnotation( Transient.class ) == null ) { |
| 622 | + checkGetAndIsVariants( containerClass, propertyName, declaredMethod, isMethod ); |
623 | 623 | } |
624 | 624 | } |
625 | | - catch (NoSuchMethodException ignore) { |
626 | | - } |
627 | 625 | } |
628 | 626 |
|
629 | 627 | public static Method getterMethodOrNull(Class<?> containerJavaType, String propertyName) { |
|
0 commit comments