danielwegener / danielwegener/xjc-immutable-plugin

Has trouble with children of abstract classes

Open
#2 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

When encountering a child, it creates a duplicate call to the superclass. At the bottom of the following generated code, the first call to super() with no arguments is incorrect. The second one, with five null arguments, is the correct call.

``` java
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.03.31 at 10:56:35 PM EDT
//

package sisostds.bml.coalition.draft.cbml._1;

import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
* A GEOMETRIC-VOLUME that has its horizontal boundaries defined by the spherical surface determined by the radius and the specified POINT.
*
*

Java class for SphereVolume complex type.
*
*

The following schema fragment specifies the expected content contained within this class.
*
*

 * <complexType name="SphereVolume">

* <complexContent>
* <extension base="{urn:sisostds:bml:coalition:draft:cbml:1}AbstractGeometricVolume">
* <sequence>
* <element name="RadiusDimension" type="{urn:int:nato:standard:mip:jc3iedm:3.0.2:oo:2.2}DimensionType12_3"/>
* <choice>
* <element name="CentrePoint" type="{urn:sisostds:bml:coalition:draft:cbml:1}AbstractPoint"/>
* <element name="CentrePointRef" type="{urn:sisostds:bml:coalition:draft:cbml:1}AbstractPointRef"/>
* </choice>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
*

*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SphereVolume", propOrder = {
"radiusDimension",
"centrePoint",
"centrePointRef"
})
public class SphereVolume
extends AbstractGeometricVolume
{

@XmlElement(name = "RadiusDimension", required = true)
protected final BigDecimal radiusDimension;
@XmlElement(name = "CentrePoint")
protected final AbstractPoint centrePoint;
@XmlElement(name = "CentrePointRef")
protected final AbstractPointRef centrePointRef;

public SphereVolume(final String oid, final VerticalDistance lowerVerticalDistance, final VerticalDistanceRef lowerVerticalDistanceRef, final VerticalDistance upperVerticalDistance, final VerticalDistanceRef upperVerticalDistanceRef, final BigDecimal radiusDimension, final AbstractPoint centrePoint, final AbstractPointRef centrePointRef) {
super(oid, lowerVerticalDistance, lowerVerticalDistanceRef, upperVerticalDistance, upperVerticalDistanceRef);
this.radiusDimension = radiusDimension;
this.centrePoint = centrePoint;
this.centrePointRef = centrePointRef;
}

/**
* Used by JAX-B
*
*/
@SuppressWarnings("unused")
protected SphereVolume() {
super();
super(null, null, null, null, null);
this.radiusDimension = null;
this.centrePoint = null;
this.centrePointRef = null;
}
```

In addition, in the ObjectFactory, it does not call the right constructor for some classes that pass arguments to a superclass:

Superclass:

``` java
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.03.31 at 10:56:35 PM EDT
//

package sisostds.bml.coalition.draft.cbml._1;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;

/**
* A reference to some GeometricVolume - A specific LOCATION that is a three-dimensional bounded space. Concrete types are: {ConeVolumeRef, SphereVolumeRef, SurfaceVolumeRef}
*
*

Java class for AbstractGeometricVolumeRef complex type.
*
*

The following schema fragment specifies the expected content contained within this class.
*
*

 * <complexType name="AbstractGeometricVolumeRef">

* <complexContent>
* <extension base="{urn:sisostds:bml:coalition:draft:cbml:1}AbstractLocationRef">
* </extension>
* </complexContent>
* </complexType>
*

*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AbstractGeometricVolumeRef")
@XmlSeeAlso({
ConeVolumeRef.class,
SphereVolumeRef.class,
SurfaceVolumeRef.class
})
public class AbstractGeometricVolumeRef
extends AbstractLocationRef
{

public AbstractGeometricVolumeRef(final String oid) {
super(oid);
}

}
```

Class created in ObjectFactory:

``` java
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.03.31 at 10:56:35 PM EDT
//

package sisostds.bml.coalition.draft.cbml._1;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

/**
* A reference to some SphereVolume - A GEOMETRIC-VOLUME that has its horizontal boundaries defined by the spherical surface determined by the radius and the specified POINT.
*
*

Java class for SphereVolumeRef complex type.
*
*

The following schema fragment specifies the expected content contained within this class.
*
*

 * <complexType name="SphereVolumeRef">

* <complexContent>
* <extension base="{urn:sisostds:bml:coalition:draft:cbml:1}AbstractGeometricVolumeRef">
* </extension>
* </complexContent>
* </complexType>
*

*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SphereVolumeRef")
public class SphereVolumeRef
extends AbstractGeometricVolumeRef
{

public SphereVolumeRef(final String oid) {
super(oid);
}

}
```

ObjectFactory factory method that has error:

``` java
/**
* Create an instance of {@link SphereVolumeRef }
*
*/
public SphereVolumeRef createSphereVolumeRef() {
return new SphereVolumeRef();
}
```

Should be:

``` java
/**
* Create an instance of {@link SphereVolumeRef }
*
*/
public SphereVolumeRef createSphereVolumeRef() {
return new SphereVolumeRef(null);
}
```

Your code is great, and these are easy errors to fix manually. However, I have a project with hundreds of auto-generated classes. This poses an issue.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.