CXF XJC toString Plugin
The CXF XJC toString Plugin provides and XJC plugin that updates the generated beans to implement toString methods to override the default Object.toString method. It uses Apache Commons Lang ToStringBuilder class to build the String, so commons-lang.jar needs to be available on the classpath.
It generates methods that look like:
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
The toString plugin can take a parameter to control what the generated toString method's style looks like.
-Xts | Activate plugin to add a toString() method to generated classes. Equivalent to: -Xts:style:org.apache.cxf.jaxb.JAXBToStringStyle.DEFAULT_STYLE |
-Xts:style:multiline | Have toString produce multi line output. Equivalent to: -Xts:style:org.apache.cxf.jaxb.JAXBToStringStyle.MULTI_LINE_STYLE |
-Xts:style:simple | Have toString produce single line terse output. Equivalent to: -Xts:style:org.apache.cxf.jaxb.JAXBToStringStyle.SIMPLE_STYLE |
-Xts:style:org.apache.commons.lang.builder.ToStringStyle.FIELD | The full class+field name of the ToStringStyle to use. |
To use with Maven
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xsdtojava</goal>
</goals>
</execution>
</executions>
<configuration>
<xsdOptions>
<xsdOption>
<extension>true</extension>
<xsd>${basedir}/src/main/resources/schemas/configuration/foo.xsd</xsd>
<extensionArgs>
<arg>-Xts:style:multiline</arg>
</extensionArgs>
</xsdOption>
</xsdOptions>
<extensions>
<extension>org.apache.cxf.xjcplugins:cxf-xjc-ts:2.3.0</extension>
</extensions>
</configuration>
</plugin>