I hava the following structure:
<data name="piece-shipment" error-status="0"
product-name="test" name="Hook" street="Freeway 21" city="Bumphill"/>
and the following jaxb annotated model..
@XmlRootElement(name = "data")
@XmlAccessorType(XmlAccessType.FIELD)
public class PieceShipment {
/**
* The field describes, of the parcel is returned to the origin sender
*/
@XmlAttribute(name = "product-name")
private String productName;
/**
* recipient information
*/
@XmlJavaTypeAdapter(RecipientAdapter.class)
private Recipient recipient;
.....
}
@XmlAccessorType(XmlAccessType.FIELD)
public class Recipient {
private String name;
private String street;
private String city;
...
}
How can I map the relation of PieceShipment to Recipient? They are on the same element level.
I've tried to use Adapters, but the adapter doesn't get called.
name
as the key: what would you do with differing address properties? And if it could be mapped, you'd end up with oodles of Recipient objects all over the place. - Best to keep it as it is, run some processing after unmarshalling everything to extract and check recipient data; handle duplicate Smiths in different cities or even same city, etc. – laune