private static void generateReadMethod ( PrefsEntity entity ) { // read method MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "read" ) . addModifiers ( Modifier . PUBLIC ) . addJavadoc ( "read bean entirely\n\n" ) . addJavadoc ( "@return read bean\n" ) . returns ( typeName ( entity . getName ( ) ) ) ; // immutable management if ( entity . isImmutablePojo ( ) ) { methodBuilder . addCode ( "\n" ) ; methodBuilder . addComment ( "initialize temporary variable for immutable POJO" ) ; ImmutableUtility . generateImmutableVariableInit ( entity , methodBuilder ) ; } else { methodBuilder . addStatement ( "$T bean=new $T()" , typeName ( entity . getName ( ) ) , typeName ( entity . getName ( ) ) ) ; } PrefsTransform transform ; for ( PrefsProperty item : entity . getCollection ( ) ) { if ( item . hasTypeAdapter ( ) ) { transform = PrefsTransformer . lookup ( item . typeAdapter . getDataTypeTypename ( ) ) ; } else { transform = PrefsTransformer . lookup ( item ) ; } if ( entity . isImmutablePojo ( ) ) { transform . generateReadProperty ( methodBuilder , "prefs" , typeName ( item . getElement ( ) . asType ( ) ) , null , item , true , ReadType . NONE ) ; } else { transform . generateReadProperty ( methodBuilder , "prefs" , typeName ( item . getElement ( ) . asType ( ) ) , "bean" , item , true , ReadType . NONE ) ; } methodBuilder . addCode ( "\n" ) ; } // immutable management if ( entity . isImmutablePojo ( ) ) { methodBuilder . addComment ( "reset temporary variable for immutable POJO" ) ; ImmutableUtility . generateImmutableEntityCreation ( entity , methodBuilder , "bean" , true ) ; } methodBuilder . addCode ( "\n" ) ; methodBuilder . addStatement ( "return bean" ) ; builder . addMethod ( methodBuilder . build ( ) ) ; }
Generate read method .