private TypeSpec generateContentValuesBuilderClass ( ObjectMappableAnnotatedClass clazz , String mapperClassName , String className ) { String cvVarName = "contentValues" ; MethodSpec constructor = MethodSpec . constructorBuilder ( ) . addModifiers ( Modifier . PRIVATE ) . addStatement ( "$L = new $T()" , cvVarName , ClassName . get ( ContentValues . class ) ) . build ( ) ; TypeSpec . Builder builder = TypeSpec . classBuilder ( className ) . addJavadoc ( "Builder class to generate type sage {@link $T } . At the end you have to call {@link #build()}\n" , TypeName . get ( ContentValues . class ) ) . addModifiers ( Modifier . PUBLIC , Modifier . STATIC ) . addField ( ContentValues . class , cvVarName , Modifier . PRIVATE ) . addMethod ( constructor ) . addMethod ( MethodSpec . methodBuilder ( "build" ) . addJavadoc ( "Creates and returns a $T from the builder\n" , TypeName . get ( ContentValues . class ) ) . addJavadoc ( "@return $T" , TypeName . get ( ContentValues . class ) ) . addModifiers ( Modifier . PUBLIC ) . addStatement ( "return $L" , cvVarName ) . returns ( ContentValues . class ) . build ( ) ) ; String packageName = getPackageName ( clazz ) ; for ( ColumnAnnotateable e : clazz . getColumnAnnotatedElements ( ) ) { e . generateContentValuesBuilderMethod ( builder , ClassName . get ( packageName , mapperClassName , className ) , cvVarName ) ; } return builder . build ( ) ; }
Generates the ContentValues Builder Class