private static void generateSingleReadMethod ( PrefsEntity entity ) { // read method PrefsTransform transform ; Converter < String , String > converter = CaseFormat . LOWER_CAMEL . converterTo ( CaseFormat . UPPER_CAMEL ) ; for ( PrefsProperty item : entity . getCollection ( ) ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "get" + converter . convert ( item . getName ( ) ) ) . addModifiers ( Modifier . PUBLIC ) . addJavadoc ( "reads property <code>$L</code> from shared pref with key <code>$L</code>\n\n" , item . getName ( ) , item . getPreferenceKey ( ) ) . addJavadoc ( "@return property $L value\n" , item . getName ( ) ) . returns ( item . getPropertyType ( ) . getTypeName ( ) ) ; if ( item . hasTypeAdapter ( ) ) { transform = PrefsTransformer . lookup ( item . typeAdapter . getDataTypeTypename ( ) ) ; } else { transform = PrefsTransformer . lookup ( item ) ; } transform . generateReadProperty ( methodBuilder , "prefs" , typeName ( item . getElement ( ) . asType ( ) ) , "defaultBean" , item , false , ReadType . RETURN ) ; builder . addMethod ( methodBuilder . build ( ) ) ; } }
Generate single read method .