title: Check if object attribute exists in java
body: <p>E.g.</p>
  
  <pre><code>[{
       'name': 'Foo',
       'distance': 2
  },{
       'name': 'Bar'
  }]
  </code></pre>
  
  <p>This will parsed into a list of objects of this class:</p>
  
  <pre><code> class City {
       public String name;
       public int distance;
   }
  </code></pre>
  
  <p>However for Bar the city object will not have the distance attribute. Can I check for types like I would check for objects? Like:</p>
  
  <pre><code>if(city.distance)
  </code></pre>
  
  <p>How can I check if distance is set?</p>