Skip to content

Instantly share code, notes, and snippets.

@danielrobertson
Created April 7, 2015 15:35
Show Gist options
  • Save danielrobertson/5cb9f8cb14500ac88360 to your computer and use it in GitHub Desktop.
Save danielrobertson/5cb9f8cb14500ac88360 to your computer and use it in GitHub Desktop.
Multiton
class Multiton {
static HashMap<String, Multiton> map = new HashMap<String, Multiton>();
private Multiton(String key) { ... }
static Multiton newMultion(String key) {
result = map.get(key);
if(result == null) {
result = new Multiton(key);
map.add(key, result);
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment