@@ -573,16 +573,15 @@ public static void verifyNoIsVariantExists(
573
573
Method getMethod ,
574
574
String stemName ) {
575
575
// 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 );
576
+ for ( Method declaredMethod : containerClass .getDeclaredMethods () ) {
577
+ if ( declaredMethod .getParameterCount () == 0
578
+ && !Modifier .isStatic ( declaredMethod .getModifiers () )
579
+ && declaredMethod .getName ().startsWith ("is" )
580
+ && declaredMethod .getName ().regionMatches (0 , stemName , 0 , stemName .length () )
581
+ && declaredMethod .getAnnotation ( Transient .class ) == null ) {
582
+ checkGetAndIsVariants ( containerClass , propertyName , getMethod , declaredMethod );
582
583
}
583
584
}
584
- catch (NoSuchMethodException ignore ) {
585
- }
586
585
}
587
586
588
587
@@ -613,17 +612,15 @@ public static void verifyNoGetVariantExists(
613
612
Method isMethod ,
614
613
String stemName ) {
615
614
// 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 );
615
+ for ( Method declaredMethod : containerClass . getDeclaredMethods () ) {
616
+ if ( declaredMethod . getParameterCount () == 0
617
+ && ! Modifier . isStatic ( declaredMethod . getModifiers () )
618
+ && declaredMethod . getName (). startsWith ( "is" )
619
+ && declaredMethod . getName (). regionMatches ( 0 , stemName , 0 , stemName . length () )
620
+ && declaredMethod .getAnnotation ( Transient .class ) == null ) {
621
+ checkGetAndIsVariants ( containerClass , propertyName , declaredMethod , isMethod );
623
622
}
624
623
}
625
- catch (NoSuchMethodException ignore ) {
626
- }
627
624
}
628
625
629
626
public static Method getterMethodOrNull (Class <?> containerJavaType , String propertyName ) {
0 commit comments