private static void addFileFunction ( CtClass clazz , String property ) throws NotFoundException , CannotCompileException { String wrapperName = property + "wrapper" ; String funcName = "set" ; funcName = funcName + Character . toUpperCase ( wrapperName . charAt ( 0 ) ) ; funcName = funcName + wrapperName . substring ( 1 ) ; String setterName = "set" ; setterName = setterName + Character . toUpperCase ( property . charAt ( 0 ) ) ; setterName = setterName + property . substring ( 1 ) ; CtClass [ ] params = generateClassField ( FileWrapper . class ) ; CtMethod newFunc = new CtMethod ( CtClass . voidType , funcName , params , clazz ) ; newFunc . setBody ( "{ " + setterName + "($1.returnFile());\n }" ) ; clazz . addMethod ( newFunc ) ; }
Adds the functionality that the models can handle File objects themselves .