how to generate wsdl client in intelij idea - java

this is the most simplified version of my problem I could generate.
I got a web service :
#WebService()
public class Service {
#WebMethod
public IsLoggedInResponse IsLoggedIn() {
return new IsLoggedInResponse();
}
}
this is the class I return:
#XmlRootElement
public class IsLoggedInResponse {
private boolean isLoggedIn;
public IsLoggedInResponse(boolean isLoggedIn) {
this.isLoggedIn = isLoggedIn;
}
public IsLoggedInResponse() {
// TODO Auto-generated constructor stub
}
#XmlElement
public boolean isLoggedIn() {
return isLoggedIn;
}
public void setLoggedIn(boolean isLoggedIn) {
this.isLoggedIn = isLoggedIn;
}
}
this is the xsd generated when pressing right click on the webserivce and generate wsdl code from java:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://webservice.pubsale.com/" xmlns:tns="http://webservice.pubsale.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="IsLoggedIn" type="tns:IsLoggedIn"/>
<xs:element name="IsLoggedInResponse" type="tns:IsLoggedInResponse"/>
<xs:element name="IsLoggedInResponse" type="tns:IsLoggedInResponse"/>
<xs:complexType name="IsLoggedIn">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="IsLoggedInResponse">
<xs:sequence>
<xs:element name="return" type="tns:isLoggedInResponse" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="isLoggedInResponse">
<xs:sequence>
<xs:element name="loggedIn" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
notice isLoggedInResponse is created twice. why? how do I stop it?

alright found the problem seems for each webmethod 'METHODNAME' JAXB creates in the schema a complex type named METHODNAMEResponse
my solution was to to add "DTO" to all my requests/responses.
could also change my method name
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://webservice.pubsale.com/" xmlns:tns="http://webservice.pubsale.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="IsLoggedIn" type="tns:IsLoggedIn"/>
<xs:element name="IsLoggedInResponse" type="tns:IsLoggedInResponse"/>
<xs:element name="isLoggedInResponseDTO" type="tns:isLoggedInResponseDTO"/>
<xs:complexType name="IsLoggedIn">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="IsLoggedInResponse">
<xs:sequence>
<xs:element name="return" type="tns:isLoggedInResponse" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

Related

How to create pojo with same xml tag in child and parent [duplicate]

This question already has answers here:
JaxB rename class with duplicate name
(1 answer)
how to rename nested classes in jaxb xjc
(2 answers)
Customize object/element name with JAXB
(2 answers)
Closed 2 years ago.
I am having an xml which has xml tags (states) same as that of parent and child. So while creating the pojos using the jaxb xjc command, I am getting 2 static inner classes with same name. I tried using bindings.xml but my problem didnt resolve and instead I am not getting error. Please find all the details below
XML:
<universe>
<cotest>
<test>
<country>
<states>
<requirement type="op">
<states>
<cashitem>
<currency>usd</currency>
<val>o</val>
</cashitem>
</states>
</requirement>
</states>
</country>
</test>
</cotest>
</universe>
This is XSD thats I generated online
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="universe">
<xs:complexType>
<xs:sequence>
<xs:element name="cotest">
<xs:complexType>
<xs:sequence>
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="country">
<xs:complexType>
<xs:sequence>
<xs:element name="states">
<xs:complexType>
<xs:sequence>
<xs:element name="requirement">
<xs:complexType>
<xs:sequence>
<xs:element name="states">
<xs:complexType>
<xs:sequence>
<xs:element name="cashitem">
<xs:complexType>
<xs:sequence>
<xs:element name="currency" type="xs:string" />
<xs:element name="val" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
bindings.xml
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings>
<jaxb:globalBindings generateElementProperty="false" fixedAttributeAsConstantProperty="true" choiceContentProperty="true" localScoping="toplevel"/>
</jaxb:bindings>
<jaxb:bindings schemaLocation="abc.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:schema//xs:element[#name='universe']//xs:sequence//xs:element[#name='states']//xs:complexType//xs:sequence//xs:element[#name='states']">
<jaxb:class name="object2" />
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
I am executing xjc using the command xjc -b bindings.xml -d photos -p com.test1 abc.xsd
error:
parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "com.test1.States" is already in us
e. Use a class customization to resolve this conflict.
line 17 of file:/D:/user/abc.xsd
[ERROR] (Relevant to above error) another "States" is generated from here.
line 23 of file:/D:/user/abc.xsd
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 17 of file:/D:/user/abc.xsd
[ERROR] (Related to above error) This is the other declaration.
line 23 of file:/D:/user/abc.xsd
Failed to produce code.
If I dont use bindings.xml then i can see classes are generated but have duplicate inner classes and hence my eclipse IDE shows compile time error
command: xjc -d photos -p com.test1 abc.xsd
package com.test1;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"cotest"
})
#XmlRootElement(name = "universe")
public class Universe {
#XmlElement(required = true)
protected Universe.Cotest cotest;
public Universe.Cotest getCotest() {
return cotest;
}
public void setCotest(Universe.Cotest value) {
this.cotest = value;
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"test"
})
public static class Cotest {
#XmlElement(required = true)
protected Universe.Cotest.Test test;
public Universe.Cotest.Test getTest() {
return test;
}
public void setTest(Universe.Cotest.Test value) {
this.test = value;
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"country"
})
public static class Test {
#XmlElement(required = true)
protected Universe.Cotest.Test.Country country;
public Universe.Cotest.Test.Country getCountry() {
return country;
}
public void setCountry(Universe.Cotest.Test.Country value) {
this.country = value;
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"states"
})
public static class Country {
#XmlElement(required = true)
protected Universe.Cotest.Test.Country.States states;
public Universe.Cotest.Test.Country.States getStates() {
return states;
}
public void setStates(Universe.Cotest.Test.Country.States value) {
this.states = value;
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"requirement"
})
public static class States {
#XmlElement(required = true)
protected Universe.Cotest.Test.Country.States.Requirement requirement;
public Universe.Cotest.Test.Country.States.Requirement getRequirement() {
return requirement;
}
public void setRequirement(Universe.Cotest.Test.Country.States.Requirement value) {
this.requirement = value;
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"states"
})
public static class Requirement {
#XmlElement(required = true)
protected Universe.Cotest.Test.Country.States.Requirement.States states;
#XmlAttribute(name = "type", required = true)
protected String type;
public Universe.Cotest.Test.Country.States.Requirement.States getStates() {
return states;
}
public void setStates(Universe.Cotest.Test.Country.States.Requirement.States value) {
this.states = value;
}
public String getType() {
return type;
}
public void setType(String value) {
this.type = value;
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"cashitem"
})
public static class States {
#XmlElement(required = true)
protected Universe.Cotest.Test.Country.States.Requirement.States.Cashitem cashitem;
public Universe.Cotest.Test.Country.States.Requirement.States.Cashitem getCashitem() {
return cashitem;
}
public void setCashitem(Universe.Cotest.Test.Country.States.Requirement.States.Cashitem value) {
this.cashitem = value;
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"currency",
"val"
})
public static class Cashitem {
#XmlElement(required = true)
protected String currency;
#XmlElement(required = true)
protected String val;
public String getCurrency() {
return currency;
}
public void setCurrency(String value) {
this.currency = value;
}
public String getVal() {
return val;
}
public void setVal(String value) {
this.val = value;
}
}
}
}
}
}
}
}
}
and this is objectfactory
package com.test1;
import javax.xml.bind.annotation.XmlRegistry;
#XmlRegistry
public class ObjectFactory {
public ObjectFactory() {
}
public Universe createUniverse() {
return new Universe();
}
public Universe.Cotest createUniverseCotest() {
return new Universe.Cotest();
}
public Universe.Cotest.Test createUniverseCotestTest() {
return new Universe.Cotest.Test();
}
public Universe.Cotest.Test.Country createUniverseCotestTestCountry() {
return new Universe.Cotest.Test.Country();
}
public Universe.Cotest.Test.Country.States createUniverseCotestTestCountryStates() {
return new Universe.Cotest.Test.Country.States();
}
public Universe.Cotest.Test.Country.States.Requirement createUniverseCotestTestCountryStatesRequirement() {
return new Universe.Cotest.Test.Country.States.Requirement();
}
public Universe.Cotest.Test.Country.States.Requirement.States createUniverseCotestTestCountryStatesRequirementStates() {
return new Universe.Cotest.Test.Country.States.Requirement.States();
}
public Universe.Cotest.Test.Country.States.Requirement.States.Cashitem createUniverseCotestTestCountryStatesRequirementStatesCashitem() {
return new Universe.Cotest.Test.Country.States.Requirement.States.Cashitem();
}
}
As you can see from the universe classs, there are 2 static inner classes public static class States and this is the issue.
Can you any please provide a solution?
Let me know if any more information required.

Mapping XMLs with different schemas to the same classes using JAXB

I have these two types of XMLs with no predefined schemas:
A
<root-a>
<a-item id="a1">
<name>Name of A1</name>
<a-item id="a11">
<name>Name of A11</name>
</a-item>
<a-item id="a12">
<name>Name of A12</name>
<a-item id="a121">
<name>Name of A121</name>
</a-item>
<a-item id="a122">
<name>Name of A122</name>
</a-item>
</a-item>
</a-item>
<a-item id="a2">
<name>Name of A2</name>
</a-item>
</root-a>
B
<root-b>
<b-item id="b1">
<name>Name of B1</name>
<b-item id="b11">
<name>Name of B11</name>
</b-item>
<!-- etc., similar to A -->
</b-item>
</root-b>
The items can be nested to an arbitrary depth. The structure is the same, but the name of the root element and of the item elements is different. How can I map it to a single Java class structure, eg. like this one (getters and setters omitted) using JAXB:
public class Root {
private List<Item> items;
}
public class Item {
private String id;
private String name;
private List<Item> items;
}
I can map just one of the XML structures using JAXB annotations, but I don't know how to do it to accommodate both XMLs at the same time. I could create a parallel hierarchy for A and B with a common interface, but I hope there's a neater solution.
Here is XML schema based on your description:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- Root elements -->
<xs:element name="root-a" type="rootAType"/>
<xs:element name="root-b" type="rootBType"/>
<!-- root-a type -->
<xs:complexType name="rootAType">
<xs:sequence>
<xs:element name="a-item" type="itemAType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- root-b type -->
<xs:complexType name="rootBType">
<xs:sequence>
<xs:element name="b-item" type="itemBType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- abstract item type -->
<xs:complexType name="itemType" abstract="true">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
<!-- item-a type -->
<xs:complexType name="itemAType">
<xs:complexContent>
<xs:extension base="itemType">
<xs:sequence>
<xs:element name="a-item" type="itemAType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- item-b type -->
<xs:complexType name="itemBType">
<xs:complexContent>
<xs:extension base="itemType">
<xs:sequence>
<xs:element name="b-item" type="itemBType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
On base of this schema following classes were created:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "itemType", propOrder = {
"name"
})
#XmlSeeAlso({
ItemAType.class,
ItemBType.class
})
public abstract class ItemType {
#XmlElement(required = true)
protected String name;
#XmlAttribute(name = "id")
protected String id;
public String getName() {
return name;
}
public void setName(String value) {
this.name = value;
}
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "itemAType", propOrder = {
"aItem"
})
public class ItemAType
extends ItemType
{
#XmlElement(name = "a-item")
protected List<ItemAType> aItem;
public List<ItemAType> getAItem() {
if (aItem == null) {
aItem = new ArrayList<ItemAType>();
}
return this.aItem;
}
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "itemBType", propOrder = {
"bItem"
})
public class ItemBType
extends ItemType
{
#XmlElement(name = "b-item")
protected List<ItemBType> bItem;
public List<ItemBType> getBItem() {
if (bItem == null) {
bItem = new ArrayList<ItemBType>();
}
return this.bItem;
}
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "rootAType", propOrder = {
"aItem"
})
public class RootAType {
#XmlElement(name = "a-item")
protected List<ItemAType> aItem;
public List<ItemAType> getAItem() {
if (aItem == null) {
aItem = new ArrayList<ItemAType>();
}
return this.aItem;
}
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "rootBType", propOrder = {
"bItem"
})
public class RootBType {
#XmlElement(name = "b-item")
protected List<ItemBType> bItem;
public List<ItemBType> getBItem() {
if (bItem == null) {
bItem = new ArrayList<ItemBType>();
}
return this.bItem;
}
}
That seems to be a bit too complicated, but if you have more common functionality between a-item and b-item, the structure will become more convenient.

why jaxb adapter annotation is not added to the proxy classes

My XSD looks like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
...
<xs:element name="person">
<xs:complexType>
...
<xs:attribute name="first_name" use="optional" type="xs:string"/>
</xs:complexType>
</xs:element>
...
</xs:schema>
I can't manage to add my adapter annotation to the concrete field ( generated proxy class must have my adapter annotation). So the result should be the following:
#XmlJavaTypeAdapter(value=StringAdapter.class, type=String.class)
#XmlAttribute(name = "first_name")
protected String firstName;
but my binding does not do anything. Just like it does not exists.
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
version="2.1">
<bindings schemaLocation="XMLreq.xsd" node="/xs:schema/xs:element[#name='person']/xs:complexType/xs:attribute[#name='first_name']" >
<xjc:javaType adapter="x.y.z.StringHashFunctionAdapter" name="java.lang.String" />
</bindings>
</jxb:bindings>
I have no error during proxy class generation.
dependencies {
xsd2java "com.sun.xml.bind:jaxb-xjc:2.2.7"
xsd2java "com.sun.xml.bind:jaxb-impl:2.2.7"
}
task xsd2java() {
doLast {
jaxbTargetDir.mkdirs()
ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.xsd2java.asPath)
ant.jaxbTargetDir = jaxbTargetDir
ant.xjc(destdir: '${jaxbTargetDir}', package: 'x.y.z.request', schema: 'src/main/resources/XMLreq.xsd', binding: 'src/main/resources/bindings.jxb')
}
}
and my adapter.
public class StringHashFunctionAdapter extends XmlAdapter<String, String> {
#Override
public String marshal(String v) throws Exception { return "####hashed value####"; }
Any ideas?

Is it possible to refer to an existing class as a base in .xsd file jaxb

I'm starting learning JAXB, so this question can be very silly. Now I have two classes, a base "base.java" and a derived class "child.java". These classes were generated using a ".xsd" file. I have another class "secondBase.java", this class was not generated by my ".xsd". My question is:
Is it possible to use "secondBase.java" as a base for "child.java" instead of the base created by my Jaxb ?
Here's my .xsd file :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.1">
<xs:complexType name="base">
<xs:sequence>
<xs:element name="id" type="xs:string" minOccurs="1"
maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:element name="chlid" />
<xs:complexType name="chlid">
<xs:complexContent>
<xs:extension base="base">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
My secondBase.java :
public class secondBase {
public secondBase(){
id="0";
}
protected String id;
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
}
My base.java (generated using .xsd file)
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "base", propOrder = {
"id"
})
#XmlSeeAlso({
Chlid.class
})
public class Base {
#XmlElement(required = true)
protected String id;
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
}
My child.java (generated using .xsd file)
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "chlid")
public class Chlid
extends Base
{
}
Thank's in advance :)
Here's the solution, it might be helpfull for someone .. I added this to my .xsd file :
<xs:complexType name="secondBase">
<xs:annotation>
<xs:appinfo>
<jaxb:class name="secondBase" implClass="com.myjaxb.classes.secondBase"/>
</xs:appinfo>
</xs:annotation>
</xs:complexType>
And i Used this "complextype as an extention to my element :)
PS : this answer is inspired from this topic : how to force schema compiled classes to extend specific class outside schema

JAXB generated classes for fixed attribute in subtype

My java classes are being generated from xsd file.
The goal I want to accomplish is to have some "known" properties based on the type of elements. For instance, I have a list of animals. After the xml is being parsed, I want to know in the code how many legs have my animals. But the number of legs is a characteristic of the animal type, so, in case I have a cat it will have 4 legs and the kangaroo will have 2 legs.
In case I define the xsd like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Animals" type="animals" />
<xs:complexType name="animals">
<xs:sequence>
<xs:element name="Animal" maxOccurs="unbounded" type="animal"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="animal" abstract="true">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="catType">
<xs:simpleContent>
<xs:extension base="animal">
<xs:attribute name="nbOfLegs" type="xs:integer" fixed="4" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="kangarooType">
<xs:simpleContent>
<xs:extension base="animal">
<xs:attribute name="nbOfLegs" type="xs:integer" fixed="2" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
The generated classes are as expected (I removed the annotations):
public abstract class Animal {
protected String name;
public String getName() {return name;}
public void setName(String value) {this.name = value;}
}
public class CatType extends Animal {
protected BigInteger nbOfLegs;
public BigInteger getNbOfLegs() {
if (nbOfLegs == null) {
return new BigInteger("4");
} else {
return nbOfLegs;
}
}
public void setNbOfLegs(BigInteger value) {this.nbOfLegs = value;}
}
This way, in case the user sets the number of legs for cats in the xml, it can only be 4, and if he doesn't, in code I will receive 4 anyway. Similar for kangaroo I always receive 2 legs.
But the problem with this approach is that I cannot use polymoprhism like this:
for(Animal animal : animals) {
System.out.println(animal.getNbOfLegs());
}
So I tried a different approach:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Animals" type="animals" />
<xs:complexType name="animals">
<xs:sequence>
<xs:element name="Animal" maxOccurs="unbounded" type="animal"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="animal" abstract="true">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" />
<xs:attribute name="nbOfLegs" type="xs:integer"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="catType">
<xs:simpleContent>
<xs:restriction base="animal">
<xs:attribute name="nbOfLegs" type="xs:integer" fixed="4" />
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="kangarooType">
<xs:simpleContent>
<xs:restriction base="animal">
<xs:attribute name="nbOfLegs" type="xs:integer" fixed="2" />
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
The Animal class is generated as expected:
public abstract class Animal {
protected String name;
protected BigInteger nbOfLegs;
public String getName() {return name;}
public void setName(String value) {this.name = value;}
public BigInteger getNbOfLegs() {return nbOfLegs;}
public void setNbOfLegs(BigInteger value) {this.nbOfLegs = value;}
}
But the generated CatType is empty.
I expected it to be like this:
public class CatType extends Animal {
#Override
public BigInteger getNbOfLegs() {
if (nbOfLegs == null) {
return new BigInteger("4");
} else {
return nbOfLegs;
}
}
}
Is it possible to customize the bindings file in order to achieve the desired generated CatType class?
Thank you.

Categories

Resources