Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ public JAnnotatable getAnnotatable(Outline outline,
},
//
ENUM("enum", AnnotatePlugin.ANNOTATE_ENUM_QNAME, AnnotatePlugin.LEGACY_ANNOTATE_ENUM_QNAME) {
@Override
public JAnnotatable getAnnotatable(Outline outline,
FieldOutline fieldOutline) {
return null;
}

@Override
public JAnnotatable getAnnotatable(Outline outline,
EnumConstantOutline enumConstantOutline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ private void annotate(final JCodeModel codeModel,
ErrorHandler errorHandler,
final CPluginCustomization customization, final Element element,
final JAnnotatable annotatable) {
if (annotatable == null) {
return;
}
final NodeList elements = element.getChildNodes();
for (int index = 0; index < elements.getLength(); index++) {
final Node node = elements.item(index);
Expand Down
86 changes: 86 additions & 0 deletions jaxb-annotate-parent/tests/annotateenum/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!--

Copyright © 2005-2015, Alexey Valikov
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-annotate-plugin-tests</artifactId>
<version>4.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>jaxb-annotate-plugin-test-annotateenum</artifactId>
<packaging>jar</packaging>
<name>JAXB Tools :: Annotate :: Test [annotate-enum]</name>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-plugin-annotate</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-annotate-plugin-test-annotations</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<configuration>
<extension>true</extension>
<args>
<arg>-Xannotate</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-plugin-annotate</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-annotate-plugin-test-annotations</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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:annox="urn:jaxb.jvnet.org:annox">
<jaxb:bindings schemaLocation="sample.xsd">
<jaxb:bindings node="//xsd:simpleType[@name='enumType']">
<annox:annotateEnum>@org.jvnet.jaxb.plugin.annotate.tests.annotations.SampleAnnotation</annox:annotateEnum>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.jvnet.jaxb.tests.annotate;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.lang.annotation.Annotation;

import org.example.sample.EnumType;
import org.jvnet.jaxb.plugin.annotate.tests.annotations.SampleAnnotation;

public class EnumTypeTest {

@Test
public void testEnum() {
Class<EnumType> c = EnumType.class;
Annotation a = c.getAnnotation(SampleAnnotation.class);
Assertions.assertNotNull(a);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.jvnet.jaxb.plugin.annotate.tests.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface SampleAnnotation {
}
1 change: 1 addition & 0 deletions jaxb-annotate-parent/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<module>annotations</module>
<module>annox</module>
<module>annotate</module>
<module>annotateenum</module>
<module>annotatepackage</module>
<module>base-dependent</module>
<module>issues</module>
Expand Down
Loading