private static void generateParserOnXmlStartElement ( BindTypeContext context , MethodSpec . Builder methodBuilder , String instanceName , String parserName , BindEntity entity ) { BindTransform bindTransform ; // start and inner bean methodBuilder . addStatement ( "currentTag = xmlParser.getName().toString()" ) ; int count = 0 ; // count property to manage { // for each elements for ( BindProperty property : entity . getCollection ( ) ) { if ( property . xmlInfo . xmlType != XmlType . TAG ) continue ; bindTransform = BindTransformer . lookup ( property ) ; // here we manage only property of bean type if ( bindTransform != null ) { count ++ ; } } } if ( count > 0 ) { // switch for tag elements // @formatter:off methodBuilder . beginControlFlow ( "switch(currentTag)$>" ) ; // for each elements for ( BindProperty property : entity . getCollection ( ) ) { if ( property . xmlInfo . xmlType != XmlType . TAG ) continue ; bindTransform = BindTransformer . lookup ( property ) ; // here we manage only property of bean type if ( bindTransform != null ) { methodBuilder . addCode ( "case $S:\n$>" , BindProperty . xmlName ( property ) ) ; methodBuilder . addCode ( "// property $L (mapped on $S)\n" , property . getName ( ) , BindProperty . xmlName ( property ) ) ; // methodBuilder.beginControlFlow("if // (!xmlParser.isEmptyElement())"); bindTransform . generateParseOnXml ( context , methodBuilder , "xmlParser" , property . getPropertyType ( ) . getTypeName ( ) , "instance" , property ) ; // methodBuilder.endControlFlow(); methodBuilder . addStatement ( "$<break" ) ; } } methodBuilder . addCode ( "default:\n$>" ) ; // methodBuilder.addStatement("$L.skipElement()", parserName); methodBuilder . addStatement ( "$<break" ) ; methodBuilder . endControlFlow ( ) ; } else { methodBuilder . addCode ( "// No property to manage here\n" ) ; } // @formatter:on }
Generate parser on xml start element .