title: JAXWS/JAXB check that an object is empty (NOT a string)
body: <p>For a Web Service, I am generating objects from WSDL/XSD. The typical XML would be like:</p>
  
  <pre><code>&lt;Document&gt;
    ...
    &lt;Destination&gt;
      &lt;Type&gt;Person&lt;/Type&gt;
      &lt;Name&gt;Someone&lt;/Name&gt;
      &lt;Address&gt;
        &lt;Street&gt;Main Street&lt;/Street&gt;
        &lt;City&gt;Foo&lt;/City&gt;
      &lt;/Address&gt;
    &lt;/Destination&gt;
    ...
  &lt;/Document&gt;
  </code></pre>
  
  <p>So, when Destination is specified, I have to validate it against a number of rules:</p>
  
  <pre><code>if (document.getDestination() != null) {
    ... check validity
  }
  </code></pre>
  
  <p>But then, someone passes:</p>
  
  <pre><code>&lt;Destination/&gt;
  </code></pre>
  
  <p>It's not null anymore and my validation rejects it. I would like to write:</p>
  
  <pre><code>if (document.getDestination() != null &amp;&amp; !document.isEmpty()) {
    ... check validity
  }
  </code></pre>
  
  <p>I don't like the idea of checking the presence of every sub-element as I will miss one at some point and create weird bugs.
  I saw the XMLNullRepresentationType from EclipseLink MOXy implementation but I'm using the Sun WebService stack. This is a pity because that would be a nice solution to my problem but it's not possible right now.</p>
  
  <p>Does anyone know of a way to check that an element is empty ? (I repeat that it is a complex type, not a String). Enumerate the properties and check them all automatically maybe ?</p>
  
  <p>Thanks.</p>