As pointed out by Sahnvour, AutoHashMap is both more convenient and will have better performance in this case.