private void addCurrencyInfo ( TypeSpec . Builder type , NumberData data ) { addCurrencyInfoMethod ( type , "getCurrencySymbol" , data . currencySymbols ) ; addCurrencyInfoMethod ( type , "getNarrowCurrencySymbol" , data . narrowCurrencySymbols ) ; addCurrencyInfoMethod ( type , "getCurrencyDisplayName" , data . currencyDisplayName ) ; MethodSpec . Builder method = MethodSpec . methodBuilder ( "getCurrencyPluralName" ) . addModifiers ( PROTECTED ) . addParameter ( Types . CLDR_CURRENCY_ENUM , "code" ) . addParameter ( PluralCategory . class , "category" ) . returns ( String . class ) ; method . beginControlFlow ( "switch (code)" ) ; for ( Map . Entry < String , Map < String , String > > currencyMap : data . currencyDisplayNames . entrySet ( ) ) { String code = currencyMap . getKey ( ) ; Map < String , String > mapping = currencyMap . getValue ( ) ; if ( mapping . isEmpty ( ) ) { continue ; } method . beginControlFlow ( "case $L:" , code ) ; method . beginControlFlow ( "switch (category)" ) ; for ( Map . Entry < String , String > entry : mapping . entrySet ( ) ) { String [ ] parts = entry . getKey ( ) . split ( "-" ) ; PluralCategory category = PluralCategory . fromString ( parts [ 2 ] ) ; if ( category == PluralCategory . OTHER ) { method . addStatement ( "case $L:\ndefault: return $S" , category , entry . getValue ( ) ) ; } else { method . addStatement ( "case $L: return $S" , category , entry . getValue ( ) ) ; } } method . endControlFlow ( ) ; method . endControlFlow ( ) ; } method . addStatement ( "default: return $S" , "" ) ; method . endControlFlow ( ) ; type . addMethod ( method . build ( ) ) ; method = MethodSpec . methodBuilder ( "getCurrencyDigits" ) . addModifiers ( PUBLIC ) . addParameter ( Types . CLDR_CURRENCY_ENUM , "code" ) . returns ( int . class ) ; method . addStatement ( "return _CurrencyUtil.getCurrencyDigits(code)" ) ; type . addMethod ( method . build ( ) ) ; }
Adds methods to return information about a currency .