Consider this request:

{
"call" : {
"type" : "Call",
"subject" : null
 }
}

This object:

@XmlRootElement(name = "call")
@XmlAccessorType(XmlAccessType.NONE)
public class ApiCallActivity {
@NotNull
@XmlElement(name = "type")
public String type;

@Size(min = 1, max = 255)
@XmlElement(name = "subject")
public String subject;
}

And this webservice:

@ApplicationScoped
@Path("/")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public class CallActivityController {
@Inject
private Logger log;
@Inject
private BeanValidator validator;
@EJB
private CallActivityService callActivityService;

@Path("/")
@POST
public void postCall(ApiCallActivity apiCall) {
log.info("postCall() apiCall.subject:{}", apiCall == null ? null :
apiCall.subject);
}
}

How come subject is a 0 length string "" not null... like a surprised
individual might discover? Is there a way to make null be null?


*Jonathan Fisher*
*VP - Information Technology*
*Spring Venture Group*

-- 
Email Confidentiality Notice: The information contained in this 
transmission is confidential, proprietary or privileged and may be subject 
to protection under the law, including the Health Insurance Portability and 
Accountability Act (HIPAA). The message is intended for the sole use of the 
individual or entity to whom it is addressed. If you are not the intended 
recipient, you are notified that any use, distribution or copying of the 
message is strictly prohibited and may subject you to criminal or civil 
penalties. If you received this transmission in error, please contact the 
sender immediately by replying to this email and delete the material from 
any computer.

Reply via email to