@Test public void testEmptyMapProperty() throws Exception { Map<String, String> values = PropertyUtil.getMap("non-existing-property"); assertEquals("Map should be empty", 0, values.size()); }
public static Map<String, String> getMap(final String propertyName) { final String[] propertiesList = getCommaSeparatedList(propertyName); if (propertiesList.length == 0) { return Collections.emptyMap(); } final Map<String, String> map = new HashMap<String, String>(); for(String str : propertiesList) { log.debug(str); final String[] vals = str.split("\\s*\\|\\s*"); log.debug(vals); if(vals.length == 2) { map.put(vals[0], vals[1]); } } return map; }
PropertyUtil { public static Map<String, String> getMap(final String propertyName) { final String[] propertiesList = getCommaSeparatedList(propertyName); if (propertiesList.length == 0) { return Collections.emptyMap(); } final Map<String, String> map = new HashMap<String, String>(); for(String str : propertiesList) { log.debug(str); final String[] vals = str.split("\\s*\\|\\s*"); log.debug(vals); if(vals.length == 2) { map.put(vals[0], vals[1]); } } return map; } }
PropertyUtil { public static Map<String, String> getMap(final String propertyName) { final String[] propertiesList = getCommaSeparatedList(propertyName); if (propertiesList.length == 0) { return Collections.emptyMap(); } final Map<String, String> map = new HashMap<String, String>(); for(String str : propertiesList) { log.debug(str); final String[] vals = str.split("\\s*\\|\\s*"); log.debug(vals); if(vals.length == 2) { map.put(vals[0], vals[1]); } } return map; }  }
PropertyUtil { public static Map<String, String> getMap(final String propertyName) { final String[] propertiesList = getCommaSeparatedList(propertyName); if (propertiesList.length == 0) { return Collections.emptyMap(); } final Map<String, String> map = new HashMap<String, String>(); for(String str : propertiesList) { log.debug(str); final String[] vals = str.split("\\s*\\|\\s*"); log.debug(vals); if(vals.length == 2) { map.put(vals[0], vals[1]); } } return map; }  static String[] getSupportedLocales(); static String getDefaultLocale(); static String[] getSupportedLanguages(); static String getDefaultLanguage(); static void setLogger(Logger logger); static void loadProperties(final String propertiesFile); static void loadProperties(final String propertiesFile, final boolean overwrite); static void clearProperties(); static String getNecessary(final String propertyName); static String getNecessary(final String propertyName, final String detailMessage); static String[] getCommaSeparatedList(final String propertyName); static Map<String, String> getMap(final String propertyName); static String getOptionalNonLocalized(final String propertyName); static String getOptional(final String propertyName); static String get(final String propertyName); static String get(final String propertyName, final String defaultValue); static int getOptional(final String propertyName, final int defaultValue); static double getOptional(final String propertyName, final double defaultValue); static boolean getOptional(final String propertyName, final boolean defaultValue); static String get(final Locale locale, final String propertyName); static String get(final Locale locale, final String propertyName, final String defaultValue); static Object getLocalizableProperty(final String key); static String getWithOptionalModifier(final String key, String... modifiers); static Object getLocalizableProperty(final String key, final String defaultValue); static List<String> getPropertyNamesStartingWith(final String prefix); static List<String> getMatchingPropertyNames(final String regex); static void addProperties(final Properties props, final boolean overwrite); static void addProperties(final Properties props); static void addProperty(final String key, final String value); static void addProperty(final String key, final String value, final boolean overwrite); static void addProperty(final String key, final String value, final Locale locale); static Properties getProperties(); }
PropertyUtil { public static Map<String, String> getMap(final String propertyName) { final String[] propertiesList = getCommaSeparatedList(propertyName); if (propertiesList.length == 0) { return Collections.emptyMap(); } final Map<String, String> map = new HashMap<String, String>(); for(String str : propertiesList) { log.debug(str); final String[] vals = str.split("\\s*\\|\\s*"); log.debug(vals); if(vals.length == 2) { map.put(vals[0], vals[1]); } } return map; }  static String[] getSupportedLocales(); static String getDefaultLocale(); static String[] getSupportedLanguages(); static String getDefaultLanguage(); static void setLogger(Logger logger); static void loadProperties(final String propertiesFile); static void loadProperties(final String propertiesFile, final boolean overwrite); static void clearProperties(); static String getNecessary(final String propertyName); static String getNecessary(final String propertyName, final String detailMessage); static String[] getCommaSeparatedList(final String propertyName); static Map<String, String> getMap(final String propertyName); static String getOptionalNonLocalized(final String propertyName); static String getOptional(final String propertyName); static String get(final String propertyName); static String get(final String propertyName, final String defaultValue); static int getOptional(final String propertyName, final int defaultValue); static double getOptional(final String propertyName, final double defaultValue); static boolean getOptional(final String propertyName, final boolean defaultValue); static String get(final Locale locale, final String propertyName); static String get(final Locale locale, final String propertyName, final String defaultValue); static Object getLocalizableProperty(final String key); static String getWithOptionalModifier(final String key, String... modifiers); static Object getLocalizableProperty(final String key, final String defaultValue); static List<String> getPropertyNamesStartingWith(final String prefix); static List<String> getMatchingPropertyNames(final String regex); static void addProperties(final Properties props, final boolean overwrite); static void addProperties(final Properties props); static void addProperty(final String key, final String value); static void addProperty(final String key, final String value, final boolean overwrite); static void addProperty(final String key, final String value, final Locale locale); static Properties getProperties();  }