Skip to content

Instantly share code, notes, and snippets.

@libliboom
Last active November 4, 2019 07:16
Show Gist options
  • Save libliboom/f3b7abb19f27371191ce46acb175c43e to your computer and use it in GitHub Desktop.
Save libliboom/f3b7abb19f27371191ce46acb175c43e to your computer and use it in GitHub Desktop.
public MapRecipe(Map<?, ?> map) {
if (map == null) throw new NullPointerException("map is null");
entries = new ArrayList<Object[]>(map.size());
if (RecipeHelper.hasDefaultConstructor(map.getClass())) {
this.typeClass = map.getClass();
} else if (map instanceof SortedMap) {
this.typeClass = TreeMap.class;
} else if (map instanceof ConcurrentMap) {
this.typeClass = ConcurrentHashMap.class;
} else {
this.typeClass = LinkedHashMap.class;
}
putAll(map);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment