You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Morten Banzon <mo...@gmail.com> on 2013/08/19 15:10:56 UTC

Is it possible to generate the equals and hashCode metods from an XSD file?

Hi !

I am trying to generate a Java class containing the methods toString, equals
and hashCode from an XSD file with the cxf-xjc-plugin version 2.6.1. I got
toString working, but I am not able to figure out how to get the CXF plugin to
generate the equals and the hashCode methods. My plugin configuration looks
like :

<plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-xjc-plugin</artifactId>
                <version>${cxf.xjc.plugin.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xsdtojava</goal>
                        </goals>

                        <configuration>

<sourceRoot>${basedir}/target/generated-sources</sourceRoot>
                            <xsdOptions>
                                <xsdOption>
                                    <extension>true</extension>

<xsd>${basedir}/src/main/resources/xsd/Message.xsd</xsd>
                                    <extensionArgs>
                                        <arg>-Xts:style:multiline</arg>
                                        <!--<arg>-Xequals</arg>-->
                                        <!--<arg>-XhashCode</arg>-->
                                    </extensionArgs>
                                </xsdOption>

                            </xsdOptions>
                            <extensions>

<extension>org.apache.cxf.xjcplugins:cxf-xjc-ts:${cxf.xjc.plugin.version}</extension>

<!--<extension>org.apache.cxf.xjcplugins:cxf-xjc-Xequals:${cxf.xjc.plugin.version}</extension>-->

<!--<extension>org.apache.cxf.xjcplugins:cxf-xjc-XhashCode:${cxf.xjc.plugin.version}</extension>-->
                            </extensions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Do you know how I can configure the CXF plugin to generate the equals and
hashCode methods ? Thanks in advance for any help,

-- Morten

Re: Is it possible to generate the equals and hashCode metods from an XSD file?

Posted by David Karlsen <da...@gmail.com>.
http://confluence.highsource.org/display/J2B/JAXB2+Basics+Plugins

Try using this artifact as a plugin:
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${jaxb2.commons.version}</version>
</dependency>
it has copy and merge functions.

<extraarg>-xjc-Xcopyable</extraarg>


2013/8/19 Morten Banzon <mo...@gmail.com>

> Hi !
>
> I am trying to generate a Java class containing the methods toString,
> equals
> and hashCode from an XSD file with the cxf-xjc-plugin version 2.6.1. I got
> toString working, but I am not able to figure out how to get the CXF
> plugin to
> generate the equals and the hashCode methods. My plugin configuration looks
> like :
>
> <plugin>
>                 <groupId>org.apache.cxf</groupId>
>                 <artifactId>cxf-xjc-plugin</artifactId>
>                 <version>${cxf.xjc.plugin.version}</version>
>                 <executions>
>                     <execution>
>                         <id>generate-sources</id>
>                         <phase>generate-sources</phase>
>                         <goals>
>                             <goal>xsdtojava</goal>
>                         </goals>
>
>                         <configuration>
>
> <sourceRoot>${basedir}/target/generated-sources</sourceRoot>
>                             <xsdOptions>
>                                 <xsdOption>
>                                     <extension>true</extension>
>
> <xsd>${basedir}/src/main/resources/xsd/Message.xsd</xsd>
>                                     <extensionArgs>
>                                         <arg>-Xts:style:multiline</arg>
>                                         <!--<arg>-Xequals</arg>-->
>                                         <!--<arg>-XhashCode</arg>-->
>                                     </extensionArgs>
>                                 </xsdOption>
>
>                             </xsdOptions>
>                             <extensions>
>
>
> <extension>org.apache.cxf.xjcplugins:cxf-xjc-ts:${cxf.xjc.plugin.version}</extension>
>
>
> <!--<extension>org.apache.cxf.xjcplugins:cxf-xjc-Xequals:${cxf.xjc.plugin.version}</extension>-->
>
>
> <!--<extension>org.apache.cxf.xjcplugins:cxf-xjc-XhashCode:${cxf.xjc.plugin.version}</extension>-->
>                             </extensions>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
>
> Do you know how I can configure the CXF plugin to generate the equals and
> hashCode methods ? Thanks in advance for any help,
>
> -- Morten
>



-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen