LocalizedMapUtil { public static Map<Locale, String> merge( Map<Locale, String> localizedMap, Locale locale, String value) { if (locale == null) { return localizedMap; } if (localizedMap == null) { return Collections.singletonMap(locale, value); } if (value != null) { localizedMap.put(locale, value); } else { localizedMap.remove(locale); } return localizedMap; }  static Map<String, String> getI18nMap(
		boolean acceptAllLanguages, Map<Locale, String> localizedMap); @Deprecated static Map<String, String> getLocalizedMap(
		boolean acceptAllLanguages, Map<Locale, String> localizedMap); static Map<Locale, String> getLocalizedMap(
		Locale defaultLocale, String defaultValue,
		Map<String, String> i18nMap); static Map<Locale, String> getLocalizedMap(
		Locale defaultLocale, String defaultValue, Map<String, String> i18nMap,
		Map<Locale, String> fallbackLocalizedMap); static Map<Locale, String> getLocalizedMap(
		Map<String, String> i18nMap); static Map<Locale, String> merge(
		Map<Locale, String> localizedMap, Locale locale, String value); static Map<Locale, String> merge(
		Map<Locale, String> localizedMap, Map.Entry<Locale, String> entry); static Map<Locale, String> patch(
		Map<Locale, String> localizedMap, Locale locale, String value); static Map<Locale, String> patch(
		Map<Locale, String> localizedMap, Locale defaultLocale,
		String defaultValue, Map<String, String> i18nMap); static void validateI18n(
		boolean add, Locale defaultLocale, String entityName,
		Map<Locale, String> localizedMap, Set<Locale> notFoundLocales);  }
@Test public void testMerge() { Map<Locale, String> map = LocalizedMapUtil.merge( null, new AbstractMap.SimpleEntry<>(LocaleUtil.US, "hello")); Assert.assertEquals(map.toString(), 1, map.size()); Assert.assertEquals("hello", map.get(LocaleUtil.US)); map = LocalizedMapUtil.merge( HashMapBuilder.put( LocaleUtil.US, "hello" ).build(), null); Assert.assertEquals(map.toString(), 1, map.size()); Assert.assertEquals("hello", map.get(LocaleUtil.US)); map = LocalizedMapUtil.merge( HashMapBuilder.put( LocaleUtil.US, "hello" ).build(), new AbstractMap.SimpleEntry<>(LocaleUtil.US, null)); Assert.assertEquals(map.toString(), 0, map.size()); Assert.assertNull(map.get(LocaleUtil.US)); map = LocalizedMapUtil.merge( HashMapBuilder.put( LocaleUtil.US, "hello" ).build(), new AbstractMap.SimpleEntry<>(LocaleUtil.FRANCE, "bonjour")); Assert.assertEquals(map.toString(), 2, map.size()); Assert.assertEquals("bonjour", map.get(LocaleUtil.FRANCE)); Assert.assertEquals("hello", map.get(LocaleUtil.US)); }