I want to create a (recursive) map of maps. That is, the value of type of the Map is another Map of the same type as the outer map.
For example:
Map<String, Map<String, Map<String, ... >>>> foo;
Evidently, I need some way to refer to "the type being defined" or something in order to do this. I guess I could do:
Map<String, Map<String, ?>>
... and then just @SupressWarnings("unchecked") myself past the inevitable warnings, but is there a better way?
Create an auxiliary class or interface to refer to "the type being defined". Like this:
class MyMap extends HashMap<String, MyMap> {
...
}
or
interface MyMap extends Map<String, MyMap> {
}
(I don't think you can do without such auxiliary class / interface. When "recursing" you need a name to refer to.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With