@Test public void testGetPluralRuleWithValidLanguageCode() throws Exception { assertThat(pluralRuleProvider.getPluralRule("en")).isNotNull().isInstanceOf(PluralRule_en.class); assertThat(pluralRuleProvider.getPluralRule("es")).isNotNull().isInstanceOf(PluralRule_es.class); assertThat(pluralRuleProvider.getPluralRule("ru")).isNotNull().isInstanceOf(PluralRule_ru.class); assertThat(pluralRuleProvider.getPluralRule("shi")).isNotNull().isInstanceOf(PluralRule_shi.class); assertThat(pluralRuleProvider.getPluralRule("tig")).isNotNull().isInstanceOf(PluralRule_tig.class); }
public PluralRule getPluralRule(String languageCode) { checkNotNull(languageCode); if (languageCode.isEmpty()) { return DEFAULT_PLURAL_RULE; } Class<?> pluralClass = loadPluralClass(languageCode); if (pluralClass == null) { return DEFAULT_PLURAL_RULE; } try { @SuppressWarnings("unchecked") PluralRule pluralRule = (PluralRule) pluralClass.newInstance(); return pluralRule; } catch (InstantiationException e) { throw new LocalizationException(e); } catch (IllegalAccessException e) { throw new LocalizationException(e); } }
PluralRuleProvider { public PluralRule getPluralRule(String languageCode) { checkNotNull(languageCode); if (languageCode.isEmpty()) { return DEFAULT_PLURAL_RULE; } Class<?> pluralClass = loadPluralClass(languageCode); if (pluralClass == null) { return DEFAULT_PLURAL_RULE; } try { @SuppressWarnings("unchecked") PluralRule pluralRule = (PluralRule) pluralClass.newInstance(); return pluralRule; } catch (InstantiationException e) { throw new LocalizationException(e); } catch (IllegalAccessException e) { throw new LocalizationException(e); } } }
PluralRuleProvider { public PluralRule getPluralRule(String languageCode) { checkNotNull(languageCode); if (languageCode.isEmpty()) { return DEFAULT_PLURAL_RULE; } Class<?> pluralClass = loadPluralClass(languageCode); if (pluralClass == null) { return DEFAULT_PLURAL_RULE; } try { @SuppressWarnings("unchecked") PluralRule pluralRule = (PluralRule) pluralClass.newInstance(); return pluralRule; } catch (InstantiationException e) { throw new LocalizationException(e); } catch (IllegalAccessException e) { throw new LocalizationException(e); } }  }
PluralRuleProvider { public PluralRule getPluralRule(String languageCode) { checkNotNull(languageCode); if (languageCode.isEmpty()) { return DEFAULT_PLURAL_RULE; } Class<?> pluralClass = loadPluralClass(languageCode); if (pluralClass == null) { return DEFAULT_PLURAL_RULE; } try { @SuppressWarnings("unchecked") PluralRule pluralRule = (PluralRule) pluralClass.newInstance(); return pluralRule; } catch (InstantiationException e) { throw new LocalizationException(e); } catch (IllegalAccessException e) { throw new LocalizationException(e); } }  PluralRule getPluralRule(String languageCode); }
PluralRuleProvider { public PluralRule getPluralRule(String languageCode) { checkNotNull(languageCode); if (languageCode.isEmpty()) { return DEFAULT_PLURAL_RULE; } Class<?> pluralClass = loadPluralClass(languageCode); if (pluralClass == null) { return DEFAULT_PLURAL_RULE; } try { @SuppressWarnings("unchecked") PluralRule pluralRule = (PluralRule) pluralClass.newInstance(); return pluralRule; } catch (InstantiationException e) { throw new LocalizationException(e); } catch (IllegalAccessException e) { throw new LocalizationException(e); } }  PluralRule getPluralRule(String languageCode);  }