Last active
August 29, 2015 14:08
-
-
Save RobertFischer/fa6e944b5489eea48ee0 to your computer and use it in GitHub Desktop.
Java Type Aliasing
This file contains hidden or 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
class Aliasing { | |
// Put your type alias right before the return value. | |
public static <L extends Long> String parseToHex(String str) { | |
return L.toHexString(L.parseLong(str)); | |
} | |
// Use this for when you have some ugly type. | |
public static <MAP extends Map<String,Set<String>>> boolean addToKey(String key, String value) { | |
MAP x = service.getKeyMap(); | |
Set<String> strings = x.get(key); | |
return strings.add(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment