JAXB doesn’t let you unmarshal already existing xml structures into HashMaps if they are not exactly the way JAXB expects them.
JAXB is fine with handling e.g. LinkedLists and filling them.
I was thinking of creating a interface with a getKey() method and a wrapper around the HashMap taking all objects that implement that interface. The wrapper can then use the getKey() method for all key related features of the map. The wrapper could then easily implement the Collection or List interface.
Because this idea doesn’t seem to innovative to me I presume that it already exists in some package, but I’m not googling correctly for it… Can someone please name a good lib that can do this, or do I have to code this myself?
You might consider extending
ForwardingListof guava, and using a HashMap in the back. I don’t know of any implementation that will leave you only the actual mapping.Another alternative is creating JAXB
XmlAdapterto adapt the values to your map. I think this one is more appropriate.