I have a DTO on my end as below
public class PassengersDto {
private List<InfantDto> infant;
private List<PassengerDto> passenger;
..getters
..setters
}
However on JAXB end I have
public class PassengerListType {
@XmlElements({
@XmlElement(name = "Infant", type = InfantType.class),
@XmlElement(name = "Passenger", type = PassengerType.class)
})
protected List<Object> passengerOrInfant;
..getter
...setter
}
I have been hitting my head with how to map from PassengerListType to PassengerDto considering that the object in list can either be InfantDto / InfantType or PassengerDto / PassengerType
I did the following mapping but this also maps infant even when its not present
<field>
<a>passengers.passengerOrInfant</a>
<b>passengers.passenger</b>
<a-hint>com.xxx.PassengerListType</a-hint>
<b-hint>com.xxx.PassengerDto</b-hint>
</field>
<field>
<a>passengers.passengerOrInfant</a>
<b>passengers.infant</b>
<a-hint>com.xxx.PassengerListType</a-hint>
<b-hint>com.xxx.InfantDto</b-hint>
</field>
Do we have any provision in Dozer to check the source object type and accordingly map to respective target object??
In this case how do I check whether the object getting mapped is of Passenger or Infant Type
No comments:
Post a Comment