private void addCurrencyInfoMethod ( TypeSpec . Builder type , String name , Map < String , String > mapping ) { MethodSpec . Builder method = MethodSpec . methodBuilder ( name ) . addModifiers ( PUBLIC ) . addParameter ( Types . CLDR_CURRENCY_ENUM , "code" ) . returns ( String . class ) ; method . beginControlFlow ( "if (code == null)" ) ; method . addStatement ( "return $S" , "" ) ; method . endControlFlow ( ) ; method . beginControlFlow ( "switch (code)" ) ; for ( Map . Entry < String , String > entry : mapping . entrySet ( ) ) { String key = entry . getKey ( ) ; String val = entry . getValue ( ) ; if ( ! key . equals ( val ) ) { method . addStatement ( "case $L: return $S" , key , val ) ; } } method . addStatement ( "default: return code.name()" ) ; method . endControlFlow ( ) ; type . addMethod ( method . build ( ) ) ; }
Adds a method to return the symbol or display name for a currency .