src/main/java/org/apache/bval/bench/Generator.java
private JVar generateBeanNonStaticInitCode(MetaJavaBean mjb, JBlock body, int level) {

        JVar beanDecl = body.decl(mjb.getGeneratedClass(), "lvl" + level + mjb.getName() + "_" + Config.CFG.nextUniqueNum());
        body.assign(beanDecl, JExpr._new(mjb.getGeneratedClass()));

        for (AbstractMetaField amf : mjb.getFields()) {
            if (amf instanceof JavaBeanRefField) {

                JavaBeanRefField jbrf = (JavaBeanRefField) amf;

                // Should a nested bean be created?
                if (Config.CFG.shouldAddNestedBean(level)) {
                    JVar nestedBeanDecl = generateBeanNonStaticInitCode(jbrf.getRefBean(), body, level + 1);
                    jbrf.generateAssignCode(body, beanDecl, nestedBeanDecl);
                }
            }

        }

        return beanDecl;
    }
/**
     * Recursive method that handles the creation of reference beans at
     * different depth levels.
     * 
     * @param mjb
     *            The target bean to create an instance of.
     * @param body
     *            The current block of code.
     * @param level
     *            The current depth level.
     * @return A generated variable referencing the created bean.
     */
Recursive method that handles the creation of reference beans at
different depth levels.

@param mjb
The target bean to create an instance of.
@param body
The current block of code.
@param level
The current depth level.
@return A generated variable referencing the created bean.
Recursive method that handles the creation of reference beans at different depth levels . @param mjb The target bean to create an instance of . @param body The current block of code . @param level The current depth level . @return A generated variable referencing the created bean .
private JVar generateBeanNonStaticInitCode(MetaJavaBean mjb, JBlock body, int level) {
        JVar beanDecl = body.decl(mjb.getGeneratedClass(), "lvl" + level + mjb.getName() + "_" + Config.CFG.nextUniqueNum());
        body.assign(beanDecl, JExpr._new(mjb.getGeneratedClass()));
        for (AbstractMetaField amf : mjb.getFields()) {
            if (amf instanceof JavaBeanRefField) {
                JavaBeanRefField jbrf = (JavaBeanRefField) amf;
                if (Config.CFG.shouldAddNestedBean(level)) {
                    JVar nestedBeanDecl = generateBeanNonStaticInitCode(jbrf.getRefBean(), body, level + 1);
                    jbrf.generateAssignCode(body, beanDecl, nestedBeanDecl);
                }
            }
        }
        return beanDecl;
    }
private JVar generateBeanNonStaticInitCode ( MetaJavaBean mjb , JBlock body , int level ) { JVar beanDecl = body . decl ( mjb . getGeneratedClass ( ) , "lvl" + level + mjb . getName ( ) + "_" + Config . CFG . nextUniqueNum ( ) ) ; body . assign ( beanDecl , JExpr . _new ( mjb . getGeneratedClass ( ) ) ) ; for ( AbstractMetaField amf : mjb . getFields ( ) ) { if ( amf instanceof JavaBeanRefField ) { JavaBeanRefField jbrf = ( JavaBeanRefField ) amf ; if ( Config . CFG . shouldAddNestedBean ( level ) ) { JVar nestedBeanDecl = generateBeanNonStaticInitCode ( jbrf . getRefBean ( ) , body , level + 1 ) ; jbrf . generateAssignCode ( body , beanDecl , nestedBeanDecl ) ; } } } return beanDecl ; }
Recursive method that handles the creation of reference beans at
 different depth levels.
Recursive method that handles the creation of reference beans at different depth levels .
// Should a nested bean be created?