You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

CXF XJC Default Value Plugin

The CXF XJC Default Value Plugin provides and XJC plugin that updates the generated beans to return the default value defined in the schema for fields that are unset in the instance.

For example, if the schema contains:

<xs:complexType name="pageColor">
  	<xs:sequence>
	    <xs:element name="background" type="xs:string" default="red"/>
	    <xs:element name="foreground" type="xs:string" default="blue"/>
   </xs:sequence>
</xs:complexType>

it would generate getter methods like:

    public String getBackground() {
        if (null == background) {
            return "red";
        }
        return background;
    }

    public String getForeground() {
        if (null == foreground) {
            return "blue";
        }
        return foreground;
    }


  • No labels