Here is the situation
private Map<String, Map<String, Map<String, String>>> properties;
And I want to have access to all levels – get Map<String, Map<String, String>>, Map<String, String> or simply just String from the inner map.
Can this be done in a better way to avoid this nested structure? Creating a wrapper which would hide the implementation and provide simple methods is the obvious solution but it just hides the main problem.
I like the
Keyapproach.And then:
Do notice that you’ll only need one map, and can still get an object with only
keyAsince it will have a different key value.Of course, if you want to store multiple objects with the same index (or recover multiple objects that start with the same key beginning, as in recover
Key("a", "a", "a")andKey("a", "a", "b)when searching forKey("a", "a", "")it will not work. But then, you should not be using aMapanyway, and should probably get a proper database.