private static CtMethod getFieldGetter ( CtField field , CtClass clazz , boolean failover ) throws NotFoundException { CtMethod method = new CtMethod ( field . getType ( ) , "descCreateMethod" , new CtClass [ ] { } , clazz ) ; String desc = method . getSignature ( ) ; String getter = getPropertyGetter ( field , failover ) ; try { return clazz . getMethod ( getter , desc ) ; } catch ( NotFoundException e ) { // try once again with getXXX instead of isXXX if ( isBooleanType ( field ) ) { return getFieldGetter ( field , clazz , true ) ; } LOGGER . debug ( String . format ( "No getter with the name '%s' and the description '%s' found" , getter , desc ) ) ; return null ; } }
Returns the getter method in case it exists or returns null if this is not the case . The failover parameter is needed to deal with boolean types since it should be allowed to allow getters in the form of isXXX or getXXX .