Hi !

I'am using CXF (2.6.1) for my projects and I would like to have a
toString() method for our generated JAXB classes.

I'am using Maven as the build system.

The easier solution seems to use the 'cxf-codegen-plugin' in
combination with the 'toString() XJC Plugin' like this :

<plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>2.6.1</version>
        <dependencies>
            <dependency>
                        <groupId>org.apache.cxf.xjcplugins</groupId>
                        <artifactId>cxf-xjc-ts</artifactId>
                        <version>2.6.0</version>
             </dependency>
        </dependencies>
        <configuration>
                <defaultOptions>
                        <extraargs>
                                
<extraarg>-xjc-Xts:style:org.apache.commons.lang.builder.ToStringStyle.SIMPLE_STYLE</extraarg>
                        </extraargs>
                </defaultOptions>
        </configuration>
        <executions>
                <execution>
                        <id>generate-sources</id>
                        <goals>
                                <goal>wsdl2java</goal>
                        </goals>
                </execution>
        </executions>
</plugin>

This will generate this :

@Override
public String toString() {
    return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}

However, as my projects are all using Guava, I would prefere to
generate the toString() method this way :

@Override
public String toString() {
    return Objects.toStringHelper(this)
        .add("name", name)
        .add("phone", phone)
        .add("eMail", eMail)
        .add("fax", fax)
        .toString();
}

Is there a plan to add this feature (using Guava) in the existing XJC Plugin ?

Thank you !

Reply via email to