Created
September 26, 2016 12:22
-
-
Save rz7d/56a6b2a2b7e62d83e2425e8e30d5b128 to your computer and use it in GitHub Desktop.
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
/** | |
* @param map Map to cast | |
* @return cast map | |
*/ | |
@SuppressWarnings("unchecked") | |
public static <K, V> Map<K, V> castMap(Map<?, ?> map) { | |
Map<K, V> result = new HashMap<K, V>(); | |
for ( Entry<?, ?> entry : map.entrySet() ) { | |
result.put((K) entry.getKey(), (V) entry.getValue()); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment