I have nested JAXB object which I would like to check for null.
if(message.getMpiParams() != null &
message.getMpiParams().getOne() != null &
message.getMpiParams().getTwo() != null &
message.getMpiParams().getThu() != null) {
...// a lot of methods here
}
When the inner object is empty I get always NPE. This is because XML tags are missing. How I can check for missing inner object safely without NPE? I just want to check for null object.
JAXB Object:
@XmlRootElement(name = "message")
@XmlAccessorType(XmlAccessType.FIELD)
public class Message{
@XmlElement(name = "mpi_params")
public MpiParams mpiParams;
}
@XmlAccessorType(XmlAccessType.FIELD)
public class MpiParams {
@XmlElement(name = "one")
public String one;
}