@Test public void testGetPluralRuleWithUnknownLanguageCode() throws Exception { PluralRule pluralRule = pluralRuleProvider.getPluralRule("blablabla"); assertThat(pluralRule).isNotNull().isInstanceOf(DefaultPluralRule.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);  }