I have made a REST API in java and I have the following DTO.
@ApiModel(value = "testType", description = "Test type")
public class TestType
{
private int type;
private String typeName;
private boolean isTypeSpecial;
private boolean isTypeTrue;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
private List<typeMasterDTO> typeMasterList;
public TestType()
{
}
@ApiModelProperty(example = "0", value = "Type", required = true)
public int getType()
{
return type;
}
public void setType(int type)
{
this.type= type;
}
@ApiModelProperty(example = "Dragon", value = "Name of the typw", required = true)
public String getTypeName()
{
return typeName;
}
public void setTypeName(String typeName)
{
this.typeName= typeName;
}
@ApiModelProperty(value = "It is a special type", required = true)
public boolean isTypeSpecial()
{
return isTypeSpecial;
}
public void setTypeSpecial(boolean isTypeSpecial)
{
this.isTypeSpecial= isTypeSpecial;
}
@ApiModelProperty(value = "It is a true type", required = true)
public boolean isTypeTrue()
{
return isTypeTrue;
}
public void setTrueType(boolean isTypeTrue)
{
this.isTypeTrue= isTypeTrue;
}
@ApiModelProperty(value = "List of types")
public List<typeMasterDTO> getTypeMasterList()
{
return typeMasterList;
}
public void setTypeMasterList(List<typeMasterDTO> typeMasterList)
{
this.typeMasterList= typeMasterList;
}
}
In my API class, I get the data for the above DTO from sql and return the response using the code:
Response com.mmp.rest.AbstractResource.buildResponse(Response<?> response, ResponseMode mode)
The output I get looks like this:
[
{
"type": 1,
"typeName": "New type",
"typeMasterList": [
{
"typeMaster": 0,
"typeMasterName": "Default"
},
{
"typeMaster": 1,
"typemasterName": "Custom"
}
],
"TypeTrue": false,
"TypeSpecial": true
}
]
So my doubts are:
- Why does the Object list come in third in the response even though I have declared it last in the DTO?
- Why is isTypeTrue and isTypeSpecial shown as TypeTrue and TypeSpecial in the output?
- Why has isTypeTrue appeared first and isTypeSpecial appeared afterwards even though I declared isTypeSpecial first?
- Is there any way i can learn how the buildResponse works?