BeanGen parse() {
        BeanData data = new BeanData();
        beanDefIndex = parseBeanDefinition();
        data.getCurrentImports().addAll(parseImports(beanDefIndex));
        data.setImportInsertLocation(parseImportLocation(beanDefIndex));
        if (beanDefIndex < 0) {
            return new BeanGen(file, content, config, data);
        }
        data.setBeanStyle(parseBeanStyle(beanDefIndex));
        data.resolveBeanStyle(config.getDefaultStyle());
        if (data.isBeanStyleValid() == false) {
            throw new BeanCodeGenException("Invalid bean style: " + data.getBeanStyle(), file, beanDefIndex);
        }
        data.setConstructorScope(parseConstrucorScope(beanDefIndex));
        if (data.isConstructorScopeValid() == false) {
            throw new BeanCodeGenException("Invalid constructor scope: " + data.getConstructorScope(), file, beanDefIndex);
        }
        data.setBeanMetaScope(parseBeanMetaScope(beanDefIndex));
        if (data.isBeanMetaScopeValid() == false) {
            throw new BeanCodeGenException("Invalid meta-bean scope: " + data.getBeanMetaScope(), file, beanDefIndex);
        }
        data.setBeanBuilderScope(parseBeanBuilderScope(beanDefIndex));
        if (data.isBeanBuilderScopeValid() == false) {
            throw new BeanCodeGenException("Invalid bean builder scope: " + data.getBeanBuilderScope(), file, beanDefIndex);
        }
        data.setFactoryName(parseFactoryName(beanDefIndex));
        data.setCacheHashCode(parseCacheHashCode(beanDefIndex));
        data.setCloneStyle(parseCloneStyle(beanDefIndex));
        if (data.isCloneStyleValid() == false) {
            throw new BeanCodeGenException("Invalid clone style: " + data.getCloneStyle(), file, beanDefIndex);
        }
        data.setImmutableConstructor(parseImmutableConstructor(beanDefIndex));
        data.setConstructable(parseConstructable(beanDefIndex));
        data.setTypeParts(parseBeanType(beanDefIndex));
        String classHeaderAfterType = classHeaderAfterType(beanDefIndex, data.getType());
        data.setSuperTypeParts(parseBeanSuperType(classHeaderAfterType));
        data.setSerializable(parseSerializable(classHeaderAfterType));
        if (parseBeanHierarchy(beanDefIndex).equals("immutable")) {
            data.setImmutable(true);
            data.setConstructorStyle(CONSTRUCTOR_BY_BUILDER);
        } else if (data.getImmutableConstructor() == CONSTRUCTOR_NONE) {
            if (data.isImmutable()) {
                if (data.isTypeFinal()) {
                    data.setConstructorStyle(CONSTRUCTOR_BY_ARGS);
                } else {
                    data.setConstructorStyle(CONSTRUCTOR_BY_BUILDER);
                }
            } else {
                if (data.isBeanStyleLight()) {
                    data.setConstructorStyle(CONSTRUCTOR_BY_ARGS);
                } else {
                    data.setConstructorStyle(CONSTRUCTOR_BY_BUILDER);
                }
            }
        } else {
            data.setConstructorStyle(data.getImmutableConstructor());
        }
        if (data.isImmutable()) {
            data.setImmutableValidator(parseImmutableValidator(beanDefIndex));
            data.setImmutableDefaults(parseImmutableDefaults(beanDefIndex));
            data.setImmutablePreBuild(parseImmutablePreBuild(beanDefIndex));
            if (data.isBeanStyleLight() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Light beans must be declared final", file, beanDefIndex);
            }
            if (data.isBeanStyleMinimal() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Minimal beans must be declared final", file, beanDefIndex);
            }
            if (data.isFactoryRequired() && !data.isRootClass()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Factory method only allowed when bean has no bean superclass", file, beanDefIndex);
            }
            if (data.isFactoryRequired() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Factory method only allowed when bean is final", file, beanDefIndex);
            }
        } else {
            if (data.isBeanStyleLight() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Light beans must be declared final", file, beanDefIndex);
            }
            if (data.isBeanStyleMinimal() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Minimal beans must be declared final", file, beanDefIndex);
            }
            if (data.isFactoryRequired()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Factory method only allowed when bean is immutable", file, beanDefIndex);
            }
        }
        properties = parseProperties(data);
        autoStartIndex = parseStartAutogen();
        autoEndIndex = parseEndAutogen();
        data.setManualSerializationId(parseManualSerializationId(beanDefIndex));
        data.setManualClone(parseManualClone(beanDefIndex));
        data.setManualEqualsHashCode(parseManualEqualsHashCode(beanDefIndex));
        data.setManualToStringCode(parseManualToStringCode(beanDefIndex));
        if (data.isImmutable()) {
            for (PropertyGen prop : properties) {
                if (prop.getData().isDerived() == false && prop.getData().isFinal() == false) {
                    throw new BeanCodeGenException("ImmutableBean must have final properties: " +
                            data.getTypeRaw() + "." + prop.getData().getFieldName(),
                            file, prop.getData().getLineIndex());
                }
            }
        } else {
            if (data.getImmutableConstructor() > CONSTRUCTOR_NONE) {
                throw new BeanCodeGenException("Mutable beans must not specify @ImmutableConstructor: " +
                        data.getTypeRaw(), file, beanDefIndex);
            }
            if (!"smart".equals(data.getConstructorScope()) && !data.isBeanStyleLight()) {
                throw new BeanCodeGenException("Mutable beans must not specify @BeanDefinition(constructorScope): " +
                                data.getTypeRaw(), file, beanDefIndex);
            }
        }
        if (data.isCacheHashCode()) {
            data.setCacheHashCode(data.isImmutable() && data.isManualEqualsHashCode() == false);
        }
        return new BeanGen(file, content, config, data, properties, autoStartIndex, autoEndIndex);
    }
BeanGen parse ( ) { BeanData data = new BeanData ( ) ; beanDefIndex = parseBeanDefinition ( ) ; data . getCurrentImports ( ) . addAll ( parseImports ( beanDefIndex ) ) ; data . setImportInsertLocation ( parseImportLocation ( beanDefIndex ) ) ; if ( beanDefIndex < 0 ) { return new BeanGen ( file , content , config , data ) ; } data . setBeanStyle ( parseBeanStyle ( beanDefIndex ) ) ; data . resolveBeanStyle ( config . getDefaultStyle ( ) ) ; if ( data . isBeanStyleValid ( ) == false ) { throw new BeanCodeGenException ( "Invalid bean style: " + data . getBeanStyle ( ) , file , beanDefIndex ) ; } data . setConstructorScope ( parseConstrucorScope ( beanDefIndex ) ) ; if ( data . isConstructorScopeValid ( ) == false ) { throw new BeanCodeGenException ( "Invalid constructor scope: " + data . getConstructorScope ( ) , file , beanDefIndex ) ; } data . setBeanMetaScope ( parseBeanMetaScope ( beanDefIndex ) ) ; if ( data . isBeanMetaScopeValid ( ) == false ) { throw new BeanCodeGenException ( "Invalid meta-bean scope: " + data . getBeanMetaScope ( ) , file , beanDefIndex ) ; } data . setBeanBuilderScope ( parseBeanBuilderScope ( beanDefIndex ) ) ; if ( data . isBeanBuilderScopeValid ( ) == false ) { throw new BeanCodeGenException ( "Invalid bean builder scope: " + data . getBeanBuilderScope ( ) , file , beanDefIndex ) ; } data . setFactoryName ( parseFactoryName ( beanDefIndex ) ) ; data . setCacheHashCode ( parseCacheHashCode ( beanDefIndex ) ) ; data . setCloneStyle ( parseCloneStyle ( beanDefIndex ) ) ; if ( data . isCloneStyleValid ( ) == false ) { throw new BeanCodeGenException ( "Invalid clone style: " + data . getCloneStyle ( ) , file , beanDefIndex ) ; } data . setImmutableConstructor ( parseImmutableConstructor ( beanDefIndex ) ) ; data . setConstructable ( parseConstructable ( beanDefIndex ) ) ; data . setTypeParts ( parseBeanType ( beanDefIndex ) ) ; String classHeaderAfterType = classHeaderAfterType ( beanDefIndex , data . getType ( ) ) ; data . setSuperTypeParts ( parseBeanSuperType ( classHeaderAfterType ) ) ; data . setSerializable ( parseSerializable ( classHeaderAfterType ) ) ; if ( parseBeanHierarchy ( beanDefIndex ) . equals ( "immutable" ) ) { data . setImmutable ( true ) ; data . setConstructorStyle ( CONSTRUCTOR_BY_BUILDER ) ; } else if ( data . getImmutableConstructor ( ) == CONSTRUCTOR_NONE ) { if ( data . isImmutable ( ) ) { if ( data . isTypeFinal ( ) ) { data . setConstructorStyle ( CONSTRUCTOR_BY_ARGS ) ; } else { data . setConstructorStyle ( CONSTRUCTOR_BY_BUILDER ) ; } } else { if ( data . isBeanStyleLight ( ) ) { data . setConstructorStyle ( CONSTRUCTOR_BY_ARGS ) ; } else { data . setConstructorStyle ( CONSTRUCTOR_BY_BUILDER ) ; } } } else { data . setConstructorStyle ( data . getImmutableConstructor ( ) ) ; } if ( data . isImmutable ( ) ) { data . setImmutableValidator ( parseImmutableValidator ( beanDefIndex ) ) ; data . setImmutableDefaults ( parseImmutableDefaults ( beanDefIndex ) ) ; data . setImmutablePreBuild ( parseImmutablePreBuild ( beanDefIndex ) ) ; if ( data . isBeanStyleLight ( ) && ! data . isTypeFinal ( ) ) { throw new BeanCodeGenException ( "Invalid bean style: Light beans must be declared final" , file , beanDefIndex ) ; } if ( data . isBeanStyleMinimal ( ) && ! data . isTypeFinal ( ) ) { throw new BeanCodeGenException ( "Invalid bean style: Minimal beans must be declared final" , file , beanDefIndex ) ; } if ( data . isFactoryRequired ( ) && ! data . isRootClass ( ) ) { throw new BeanCodeGenException ( "Invalid bean style: Factory method only allowed when bean has no bean superclass" , file , beanDefIndex ) ; } if ( data . isFactoryRequired ( ) && ! data . isTypeFinal ( ) ) { throw new BeanCodeGenException ( "Invalid bean style: Factory method only allowed when bean is final" , file , beanDefIndex ) ; } } else { if ( data . isBeanStyleLight ( ) && ! data . isTypeFinal ( ) ) { throw new BeanCodeGenException ( "Invalid bean style: Light beans must be declared final" , file , beanDefIndex ) ; } if ( data . isBeanStyleMinimal ( ) && ! data . isTypeFinal ( ) ) { throw new BeanCodeGenException ( "Invalid bean style: Minimal beans must be declared final" , file , beanDefIndex ) ; } if ( data . isFactoryRequired ( ) ) { throw new BeanCodeGenException ( "Invalid bean style: Factory method only allowed when bean is immutable" , file , beanDefIndex ) ; } } properties = parseProperties ( data ) ; autoStartIndex = parseStartAutogen ( ) ; autoEndIndex = parseEndAutogen ( ) ; data . setManualSerializationId ( parseManualSerializationId ( beanDefIndex ) ) ; data . setManualClone ( parseManualClone ( beanDefIndex ) ) ; data . setManualEqualsHashCode ( parseManualEqualsHashCode ( beanDefIndex ) ) ; data . setManualToStringCode ( parseManualToStringCode ( beanDefIndex ) ) ; if ( data . isImmutable ( ) ) { for ( PropertyGen prop : properties ) { if ( prop . getData ( ) . isDerived ( ) == false && prop . getData ( ) . isFinal ( ) == false ) { throw new BeanCodeGenException ( "ImmutableBean must have final properties: " + data . getTypeRaw ( ) + "." + prop . getData ( ) . getFieldName ( ) , file , prop . getData ( ) . getLineIndex ( ) ) ; } } } else { if ( data . getImmutableConstructor ( ) > CONSTRUCTOR_NONE ) { throw new BeanCodeGenException ( "Mutable beans must not specify @ImmutableConstructor: " + data . getTypeRaw ( ) , file , beanDefIndex ) ; } if ( ! "smart" . equals ( data . getConstructorScope ( ) ) && ! data . isBeanStyleLight ( ) ) { throw new BeanCodeGenException ( "Mutable beans must not specify @BeanDefinition(constructorScope): " + data . getTypeRaw ( ) , file , beanDefIndex ) ; } } if ( data . isCacheHashCode ( ) ) { data . setCacheHashCode ( data . isImmutable ( ) && data . isManualEqualsHashCode ( ) == false ) ; } return new BeanGen ( file , content , config , data , properties , autoStartIndex , autoEndIndex ) ; }
-----------------------------------------------------------------------