I have this JSON:
{
"label":{
"label":"1D812",
"version":"01"
},
"productionDate":"140415",
"boxNumber":"003",
"quantity":11000,
"order":"0000",
"documentId":"DOC-HHS",
"location":1
}
and I run these commands to create a Box
object
ObjectMapper mapper = new ObjectMapper();
Box box = mapper.readValue(myJSON, Box.class);
In Box
class there is the following constructor:
public Box(Label label, String productionDate, String boxNumber, int quantity, String order, String documentId,int location ) {
this.label = label;
this.quantity = quantity;
this.order = order;
this.boxNumber = boxNumber;
this.location = location;
this.documentId = documentId;
this.productionDate = productionDate;
}
And in Label
class I have these constructors (in that order, if it matters)
public Label() {
}
public Label(String label) {
this.label = label;
}
public Label(String label, String version) {
this.label = label;
this.version = version;
}
public Label(String label, String version, SupplierL supplier) {
this.label = label;
this.version = version;
this.supplier = supplier;
this.labelWithVersion = label + "-" + version;
}
When I System.out.println(box.toString());
I see that:
Box{label=Label{label=1D812, version=01, supplier=null}, etc...}
I am wondering, why it used the Label
constructor with the 3 arguments and not that with the 2?