XML which I want to unmarshall to java object:
<API Name="A">
<Input>
<Shipment
EnterpriseCode="ABC"
SellerOrganizationCode="6528"
ShipNode=""
ShipmentKey="202105171041273117421546">
<ShipmentLines>
<ShipmentLine BackroomPickedQuantity="2.0"
ShipmentLineKey="41273117421545">
<Extn
ExtnStagingLocation="location1"/>
</ShipmentLine>
</ShipmentLines>
<Extn ExtnInPickupLocker="N"
ExtnPickerId="1531685"
ExtnPickingHasStartedFlag="Y"
ExtnStagedByUserName="Windows and Walls"
ExtnStagingLocation=""/>
</Shipment>
</Input>
</API>
Below is the EXTN and EXTN1 java classes which I trying to map with XML have used JAXB and JACKSON to identify and map the variables with EXTN tag to java class Extn and Extn1.
@XmlAccessorType(XmlAccessType.FIELD)
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public static class Extn {
@JsonProperty(value = "ExtnStagingLocation")
@JacksonXmlProperty(isAttribute = true)
private String extnStagingLocation = "location1";
@JsonProperty(value = "ExtnInPickupLocker")
@XmlAttribute(name = "ExtnInPickupLocker", required = true)
private String extnInPickupLocker = "N";
@JsonProperty(value = "ExtnPickerId")
@JacksonXmlProperty(isAttribute = true)
private String extnPickerId = "1531685";
@JsonProperty(value = "ExtnPickingHasStartedFlag")
@JacksonXmlProperty(isAttribute = true)
private String extnPickingHasStartedFlag = "Y";
@JsonProperty(value = "ExtnStagedByUserName")
@JacksonXmlProperty(isAttribute = true)
private String ExtnStagedByUserName = "Windows and Walls";
}
@XmlAccessorType(XmlAccessType.FIELD)
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public static class Extn1 {
@JsonProperty(value = "ExtnStagingLocation")
@JacksonXmlProperty(isAttribute = true)
private String extnStagingLocation = "location1";
}
How do I Create a single class EXTN and then pass the desired attributes at different level while creating java object, rather creating different java class Extn and Extn1 and map the attributes inside the Extn tag
Note: Have created EXTN and EXTN1 to pass different attribute and it's value at different place