private MethodSpec buildWrapTimeZoneGMTMethod ( TimeZoneData data ) { String [ ] hourFormat = data . hourFormat . split ( ";" ) ; List < Node > positive = DATETIME_PARSER . parse ( hourFormat [ 0 ] ) ; List < Node > negative = DATETIME_PARSER . parse ( hourFormat [ 1 ] ) ; List < Node > format = WRAPPER_PARSER . parseWrapper ( data . gmtFormat ) ; MethodSpec . Builder method = MethodSpec . methodBuilder ( "wrapTimeZoneGMT" ) . addModifiers ( PROTECTED ) . addParameter ( StringBuilder . class , "b" ) . addParameter ( boolean . class , "neg" ) . addParameter ( int . class , "hours" ) . addParameter ( int . class , "mins" ) . addParameter ( boolean . class , "_short" ) ; // Special format for zero method . beginControlFlow ( "if (hours == 0 && mins == 0)" ) ; method . addStatement ( "b.append($S)" , data . gmtZeroFormat ) ; method . addStatement ( "return" ) ; method . endControlFlow ( ) ; method . addStatement ( "boolean emitMins = !_short || mins > 0" ) ; for ( Node node : format ) { if ( node instanceof Text ) { Text text = ( Text ) node ; method . addStatement ( "b.append($S)" , text . text ( ) ) ; } else { method . beginControlFlow ( "if (neg)" ) ; appendHourFormat ( method , negative ) ; method . endControlFlow ( ) ; method . beginControlFlow ( "else" ) ; appendHourFormat ( method , positive ) ; method . endControlFlow ( ) ; } } return method . build ( ) ; }
Builds a method to format the timezone as hourFormat with a GMT wrapper .