title: Null check chain vs catching NullPointerException
body: <p>A web service returns a huge XML and I need to access deeply nested fields of it. For example:</p>
  
  <pre><code>return wsObject.getFoo().getBar().getBaz().getInt()
  </code></pre>
  
  <p>The problem is that <code>getFoo()</code>, <code>getBar()</code>, <code>getBaz()</code> may all return <code>null</code>.</p>
  
  <p>However, if I check for <code>null</code> in all cases, the code becomes very verbose and hard to read. Moreover, I may miss the checks for some of the fields.</p>
  
  <pre><code>if (wsObject.getFoo() == null) return -1;
  if (wsObject.getFoo().getBar() == null) return -1;
  // maybe also do something with wsObject.getFoo().getBar()
  if (wsObject.getFoo().getBar().getBaz() == null) return -1;
  return wsObject.getFoo().getBar().getBaz().getInt();
  </code></pre>
  
  <p>Is it acceptable to write</p>
  
  <pre><code>try {
      return wsObject.getFoo().getBar().getBaz().getInt();
  } catch (NullPointerException ignored) {
      return -1;
  }
  </code></pre>
  
  <p>or would that be considered an antipattern?</p>