Skip to content

Commit

Permalink
Added fromMap() method
Browse files Browse the repository at this point in the history
  • Loading branch information
sangupta committed Apr 6, 2015
1 parent b9dc2fb commit 7b9ee11
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/com/sangupta/jerry/util/PropertiesUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,30 @@ public static Map<String, String> asMap(Properties properties) {

return map;
}

/**
* Convert a given {@link Map} instance to a corresponding
* {@link Properties} instance
*
* @param map
* @return
*/
public static Properties fromMap(Map<String, String> map) {
if(map == null) {
return null;
}

Properties properties = new Properties();
if(map.isEmpty()) {
return properties;
}

Set<String> keys = map.keySet();
for(String key : keys) {
properties.setProperty(key, map.get(key));
}

return properties;
}

}

0 comments on commit 7b9ee11

Please sign in to comment.