private void generatePopulate ( SQLiteDatabaseSchema schema , MethodSpec . Builder methodBuilder , boolean instance ) { methodBuilder . beginControlFlow ( "try" ) ; methodBuilder . addStatement ( "instance.openWritableDatabase()" ) ; methodBuilder . addStatement ( "instance.close()" ) ; if ( ( instance && schema . configPopulatorClazz != null ) || ( ! instance ) ) { methodBuilder . addComment ( "force database DDL run" ) ; methodBuilder . beginControlFlow ( "if (options.populator!=null && instance.justCreated)" ) ; methodBuilder . addComment ( "run populator only a time" ) ; methodBuilder . addStatement ( "instance.justCreated=false" ) ; // populator manage its connection // methodBuilder.beginControlFlow("try"); // methodBuilder.addStatement("$T // currentDb=instance.openWritableDatabase()", // SQLiteDatabase.class); methodBuilder . addComment ( "run populator" ) ; methodBuilder . addStatement ( "options.populator.execute()" ) ; // methodBuilder.nextControlFlow("finally"); // methodBuilder.addStatement("instance.close()"); // methodBuilder.endControlFlow(); methodBuilder . endControlFlow ( ) ; } methodBuilder . nextControlFlow ( "catch($T e)" , Throwable . class ) ; methodBuilder . addStatement ( "$T.error(e.getMessage())" , Logger . class ) ; methodBuilder . addStatement ( "e.printStackTrace()" ) ; methodBuilder . endControlFlow ( ) ; }
Generate populate .