Я сделал REST API в Java, и у меня есть следующий 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;
}
}
В моем классе API я получаю данные для вышеуказанного DTO из sql и возвращаю ответ, используя код:
Response com.mmp.rest.AbstractResource.buildResponse(Response<?> response, ResponseMode mode)
Вывод, который я получаю, выглядит следующим образом:
[
{
"type": 1,
"typeName": "New type",
"typeMasterList": [
{
"typeMaster": 0,
"typeMasterName": "Default"
},
{
"typeMaster": 1,
"typemasterName": "Custom"
}
],
"TypeTrue": false,
"TypeSpecial": true
}
]
Итак, мои сомнения:
- Почему список объектов занимает третье место в ответе, хотя я объявил его последним в DTO?
- Почему isTypeTrue и isTypeSpecial показываются как TypeTrue и TypeSpecial в выводе?
- Почему isTypeTrue появился первым, а isTypeSpecial появился позже, хотя я сначала объявил isTypeSpecial?
- Есть ли способ узнать, как работает buildResponse?