public static void generate ( Path outputDir ) throws IOException { DataReader reader = DataReader . get ( ) ; CalendarCodeGenerator datetimeGenerator = new CalendarCodeGenerator ( ) ; Map < LocaleID , ClassName > dateClasses = datetimeGenerator . generate ( outputDir , reader ) ; PluralCodeGenerator pluralGenerator = new PluralCodeGenerator ( ) ; pluralGenerator . generate ( outputDir , reader ) ; NumberCodeGenerator numberGenerator = new NumberCodeGenerator ( ) ; Map < LocaleID , ClassName > numberClasses = numberGenerator . generate ( outputDir , reader ) ; LanguageCodeGenerator languageGenerator = new LanguageCodeGenerator ( ) ; languageGenerator . generate ( outputDir , reader ) ; MethodSpec registerCalendars = indexFormatters ( "registerCalendars" , "registerCalendarFormatter" , dateClasses ) ; MethodSpec registerNumbers = indexFormatters ( "registerNumbers" , "registerNumberFormatter" , numberClasses ) ; MethodSpec constructor = MethodSpec . constructorBuilder ( ) . addModifiers ( PRIVATE ) . build ( ) ; FieldSpec instance = FieldSpec . builder ( CLDR , "instance" , PRIVATE , STATIC , FINAL ) . build ( ) ; MethodSpec getter = MethodSpec . methodBuilder ( "get" ) . addModifiers ( PUBLIC , STATIC ) . returns ( CLDR ) . addStatement ( "return instance" ) . build ( ) ; TypeSpec . Builder type = TypeSpec . classBuilder ( "CLDR" ) . addModifiers ( PUBLIC ) . superclass ( CLDR_BASE ) . addMethod ( constructor ) . addMethod ( getter ) . addMethod ( registerCalendars ) . addMethod ( registerNumbers ) ; Set < LocaleID > availableLocales = reader . availableLocales ( ) . stream ( ) . map ( s -> LocaleID . parse ( s ) ) . collect ( Collectors . toSet ( ) ) ; createLocales ( type , reader . defaultContent ( ) , availableLocales ) ; createLanguageAliases ( type , reader . languageAliases ( ) ) ; createTerritoryAliases ( type , reader . territoryAliases ( ) ) ; createLikelySubtags ( type , reader . likelySubtags ( ) ) ; createCurrencies ( type , numberGenerator . getCurrencies ( reader ) ) ; addPluralRules ( type ) ; // Initialize all static maps. type . addStaticBlock ( CodeBlock . builder ( ) . addStatement ( "registerCalendars()" ) . addStatement ( "registerNumbers()" ) . addStatement ( "registerDefaultContent()" ) . addStatement ( "registerLanguageAliases()" ) . addStatement ( "registerTerritoryAliases()" ) . addStatement ( "registerLikelySubtags()" ) . addStatement ( "instance = new CLDR()" ) . build ( ) ) ; type . addField ( instance ) ; saveClass ( outputDir , PACKAGE_CLDR , "CLDR" , type . build ( ) ) ; }
Loads all CLDR data and invokes the code generators for each data type . Output is a series of Java classes under the outputDir .