Created
April 20, 2015 14:26
-
-
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)!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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