title: JAXB xjc: How to generate code for Strings that returns empty if the value is null?
body: <p>Given the following example xsd snippet:</p>
  
  <pre><code>&lt; xs:attribute name="SEGMENT"  default="" use="optional" type="xs:string"/ &gt;
  </code></pre>
  
  <p>when xjc generates the class containing the <code>SEGMENT</code> bean attribute, the following getter is auto-generated:</p>
  
  <pre><code>public String getSEGMENT() {
      if (segment == null) {
          return "";
      } else {
          return segment;
      }
  }
  </code></pre>
  
  <p>My question is how do you get it do the same for <code>xs:element</code> objects? In other words, given the following xsd snippet:</p>
  
  <pre><code>&lt; xs:element name="NAME" default="" type="xs:string"/ &gt;
  </code></pre>
  
  <p>I want to know if I can get xjc to generate the following:</p>
  
  <pre><code>public String getNAME() {
      if (name == null) {
          return "";
      } else {
          return name;
      }
  }
  </code></pre>
  
  <p>How can this be done?</p>