-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Labels
Milestone
Description
I've got a problem with the JAXB Annotate Plugin and annotations for enum types. There are unwanted/unexpected annotations on getters that return an enum type value.
sample.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.example.org/sample"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/sample"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="enumType">
<xs:restriction base="xs:string">
<xs:enumeration value="VALUE_1"/>
<xs:enumeration value="VALUE_2"/>
<xs:enumeration value="VALUE_3"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="enumWithCommentType">
<xs:simpleContent>
<xs:extension base="enumType">
<xs:attribute name="comment" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>sample.jxb:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="3.0"
xmlns:namespace="urn:jaxb.jvnet.org:plugin:namespace-prefix"
xmlns:annox="urn:jaxb.jvnet.org:annox">
<jaxb:bindings schemaLocation="sample.xsd">
<jaxb:bindings>
<namespace:prefix name="sample"/>
</jaxb:bindings>
<jaxb:bindings node="//xsd:simpleType[@name='enumType']">
<annox:annotate>
<annox:annotate annox:class="org.example.annotation.SampleAnnotation"/>
</annox:annotate>
<jaxb:bindings multiple="true" node="xsd:restriction/xsd:enumeration">
<annox:annotate>
<annox:annotate annox:class="java.lang.Deprecated"/>
</annox:annotate>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>SampleAnnotation.java:
package org.example.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SampleAnnotation
{
}Resulting EnumType.java
//
// This file was generated by the Eclipse Implementation of JAXB, v4.0.6
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
//
package org.example.sample;
import jakarta.xml.bind.annotation.XmlEnum;
import jakarta.xml.bind.annotation.XmlType;
import org.example.annotation.SampleAnnotation;
/**
*
*
* <p>Java class for enumType</p>.
*
* <p>The following schema fragment specifies the expected content contained within this class.</p>
* <pre>{@code
* <simpleType name="enumType">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="VALUE_1"/>
* <enumeration value="VALUE_2"/>
* <enumeration value="VALUE_3"/>
* </restriction>
* </simpleType>
* }</pre>
*
*/
@XmlType(name = "enumType")
@XmlEnum
@SampleAnnotation
public enum EnumType {
VALUE_1,
VALUE_2,
VALUE_3;
public String value() {
return name();
}
public static EnumType fromValue(String v) {
return valueOf(v);
}
}Resulting EnumWithCommentType.java
//
// This file was generated by the Eclipse Implementation of JAXB, v4.0.6
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
//
package org.example.sample;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlValue;
import org.example.annotation.SampleAnnotation;
/**
* <p>Java class for enumWithCommentType complex type</p>.
*
* <p>The following schema fragment specifies the expected content contained within this class.</p>
*
* <pre>{@code
* <complexType name="enumWithCommentType">
* <simpleContent>
* <extension base="<http://www.example.org/sample>enumType">
* <attribute name="comment" type="{http://www.w3.org/2001/XMLSchema}string" />
* </extension>
* </simpleContent>
* </complexType>
* }</pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "enumWithCommentType", propOrder = {
"value"
})
public class EnumWithCommentType {
@XmlValue
protected EnumType value;
@XmlAttribute(name = "comment")
protected String comment;
/**
* Gets the value of the value property.
*
* @return
* possible object is
* {@link EnumType }
*
*/
@SampleAnnotation
public EnumType getValue() {
return value;
}
/**
* Sets the value of the value property.
*
* @param value
* allowed object is
* {@link EnumType }
*
*/
public void setValue(EnumType value) {
this.value = value;
}
/**
* Gets the value of the comment property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getComment() {
return comment;
}
/**
* Sets the value of the comment property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setComment(String value) {
this.comment = value;
}
}As you can see there are two occurences of @SampleAnnotation. One at the enum declaration in EnumType.java. An one at the getter public EnumType getValue() in EnumWithCommentType. The first one ist wanted/expected. The second one is unwanted/unexpected. Is this a bug or a configuration issue?
Kind regards,
Martin
Reactions are currently unavailable