I have a few model classes that extend LinkedHashMap
: they define getters and setters which wrap the Map\'s get and put methods. I am tryi
I have a few model classes that extend
LinkedHashMap
: they define getters and setters which wrap the Map's get and put methods
This is a classic example of when not to use inheritance: you're finding that some other piece of code (i.e. Jackson) is treating your class like an instance of its superclass, which isn't what you want it to do. In cases like these (and also in general), it's usually better to use composition rather than inheritance.
I recommend rewriting your model class to contain a map, rather than extending one. You get much more control than way, and the resulting model is less brittle. If you need to view your model as a Map
, then implement an asMap
method (or something similar) which renders that view.