Before I reinvent the wheel does java already have this data structure: Map<String, Map<String, String>>
as a single type?
I need to be able to call .get(key)
and it return a Map<String, String>
.
Or is there a common library that has it?
Before I reinvent the wheel does java already have this data structure: Map<String, Map<String, String>>
as a single type?
I need to be able to call .get(key)
and it return a Map<String, String>
.
Or is there a common library that has it?
To sum up what people have written in the comments (if I may), you have plenty of options here:
Map<String,Map<String,String>>
, as Tichodroma suggests (after all it's not so complicated).Map<Pair<String,String>, String>
where Pair
is either a class that you defined, or one of Apache Common's Pair classes, like this one, as aioobe suggest. Keep in mind, however, that there is a reason why Java doesn't have a Pair class.<String,String,String>
, or ImmutableTable (as Quantas adds), which do exactly what you want. See this post for more details.Plase, do not upvote/accept this answer, unless you picked the last option.