Question

I have two classes A and B generated by cxf-codegen-plugin from my WSDL. A inherits from B.

I would like to add common methods like hashCode(), equals()... So, I have the following configuration in my POM:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.6.0</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/wsdl/PeeringApi.wsdl</wsdl>
                        <extraargs>
                            <extraarg>-xjc-XhashCode</extraarg>
                            <extraarg>-xjc-Xequals</extraarg>
                            <extraarg>-xjc-Xsetters</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics</artifactId>
            <version>${jaxb2.version}</version>
        </dependency>
    </dependencies> </plugin>

I have two questions:

  1. Is there a way to generate an equals() method that doesn't compare properties of B (i.e. not calling super.equals())?
  2. How to indicate to the plugin to generate an equals() method that compare only certain properties of A (by default, it seems that all the properties are compared) that I specify?

Thanks

Was it helpful?

Solution

I've found a solution as it is explained here: http://confluence.highsource.org/display/J2B/JAXB2+Basics+Plugins.

You can add custom bindings to indicate to JAXB2 plugins to ignore a certain property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top