Skip to content

Instantly share code, notes, and snippets.

@fernandodev
Created April 20, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandodev/c1a6af088d81dc85b9e4 to your computer and use it in GitHub Desktop.
Save fernandodev/c1a6af088d81dc85b9e4 to your computer and use it in GitHub Desktop.
A Hash Util (Build hash as easy as possible). Just map("key", value)!
/**
* Created by fernandomartinez on 12/22/14.
*/
public class HashUtils {
public static Map map(Object... keyValuePair) {
Map<Object, Object> map = new HashMap<>();
for (int i = 0; i < keyValuePair.length; i += 2) {
if (( i + 1 ) < keyValuePair.length &&
keyValuePair[i] != null &&
keyValuePair[i + 1] != null) {
map.put(keyValuePair[i], keyValuePair[i + 1]);
} else {
continue;
}
}
return map;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment