Несмотря на то, что я определил @XmlElement
с помощью nillable = false
и required = true
, веб-служба все еще принимает нулевые значения для данного элемента.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CompanyPreference")
public class CompanyPreference {
public CompanyPreference() {
super();
}
@XmlElement(nillable = false, required = true)
private String preferenceName;
@XmlElement(nillable = false, required = true)
private String preferenceType;
.
.
.
Тогда в моем веб-сервисе
@POST
@SecureIt
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(value = { MediaType.APPLICATION_JSON })
@Path("/preferences")
@ApiOperation(value = "Update Company Preferences", response = DefaultResponse.class, authorizations = { @Authorization(value="Bearer") })
public Response savePreferences(CompanyPreference[] companyPreferences, //This is the array
@Context ContainerRequestContext crc) throws ResponseError {
Массив настроек, которые я передаю
[
{
"preferenceName": null,
"preferenceType": null
}
]
Почему я все еще могу передать пустые значения в моем объекте и получить успешный ответ? Я что-то упустил?