Skip to content

Commit c3fb9ad

Browse files
committed
Fixes #11.
1 parent feac076 commit c3fb9ad

File tree

67 files changed

+334
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+334
-473
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ You can use the following customization elements in the `http://annox.dev.java.n
118118
* `annotateElement`
119119
* `annotateEnum`
120120
* `annotateEnumConstant`
121-
* `annotateEnumValueMethod` - place annotation above `value()` method
122-
* `annotateEnumFromValueMethod` - place annotation above `fromValue(String)` method
121+
* `annotateEnumValueMethod` - annotate the `value()` method of the enum
122+
* `annotateEnumFromValueMethod` - annotate the `fromValue(String)` method of the enum
123123

124124
The `http://annox.dev.java.net` namespace must be declared in the `jaxb:extensionBindingPrefixes` attribute via prefix, ex.:
125125

plugin/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/AnnotatePlugin.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,19 @@ private void annotate(final JCodeModel codeModel,
393393

394394
@Override
395395
public Collection<QName> getCustomizationElementNames() {
396-
return Arrays.asList(ANNOTATE_QNAME, ANNOTATE_PACKAGE_QNAME,
397-
ANNOTATE_CLASS_QNAME, ANNOTATE_ELEMENT_QNAME,
398-
ANNOTATE_PROPERTY_QNAME, ANNOTATE_PROPERTY_FIELD_QNAME,
399-
ANNOTATE_PROPERTY_GETTER_QNAME, ANNOTATE_PROPERTY_SETTER_QNAME,
400-
ANNOTATE_PROPERTY_SETTER_PARAMETER_QNAME, ANNOTATE_ENUM_QNAME,
401-
ANNOTATE_ENUM_CONSTANT_QNAME, ANNOTATE_ENUM_VALUE_METHOD_QNAME,
396+
return Arrays.asList(
397+
ANNOTATE_QNAME,
398+
ANNOTATE_PACKAGE_QNAME,
399+
ANNOTATE_CLASS_QNAME,
400+
ANNOTATE_ELEMENT_QNAME,
401+
ANNOTATE_PROPERTY_QNAME,
402+
ANNOTATE_PROPERTY_FIELD_QNAME,
403+
ANNOTATE_PROPERTY_GETTER_QNAME,
404+
ANNOTATE_PROPERTY_SETTER_QNAME,
405+
ANNOTATE_PROPERTY_SETTER_PARAMETER_QNAME,
406+
ANNOTATE_ENUM_QNAME,
407+
ANNOTATE_ENUM_CONSTANT_QNAME,
408+
ANNOTATE_ENUM_VALUE_METHOD_QNAME,
402409
ANNOTATE_ENUM_FROM_VALUE_METHOD_QNAME);
403410
}
404411

plugin/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/AnnotationTarget.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,10 @@ public JAnnotatable getAnnotatable(Outline outline,
220220
throws IllegalArgumentException, UnsupportedOperationException {
221221
final JMethod valueMethod = enumOutline.clazz.getMethod("value", new JType[0]);
222222
if (null == valueMethod) {
223-
throw new UnsupportedOperationException(MessageFormat.format(
224-
"Method value() not found in enum [{0}]",
225-
enumOutline.clazz.name()));
223+
throw new IllegalArgumentException(
224+
MessageFormat
225+
.format("Could not annotate the value() method of the enum [{0}] since it could not be found.",
226+
enumOutline.clazz.name()));
226227
}
227228
return valueMethod;
228229
}
@@ -237,9 +238,11 @@ public JAnnotatable getAnnotatable(Outline outline,
237238
final JType jTypeString = codeModel._ref(String.class);
238239
final JMethod fromValueMethod = enumOutline.clazz.getMethod("fromValue", new JType[]{jTypeString});
239240
if (null == fromValueMethod) {
240-
throw new UnsupportedOperationException(MessageFormat.format(
241-
"Method fromValue(String) not found in enum [{0}]",
242-
enumOutline.clazz.name()));
241+
throw new IllegalArgumentException(
242+
MessageFormat
243+
.format("Could not annotate the fromValue(String) method of the enum [{0}] since it could not be found.",
244+
enumOutline.clazz.name()));
245+
243246
}
244247
return fromValueMethod;
245248
}

pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
</dependency>
218218
<dependency>
219219
<groupId>com.sun.xml.bind</groupId>
220-
<artifactId>jaxb-core</artifactId>
220+
<artifactId>jaxb-impl</artifactId>
221221
<version>${jaxb.version}</version>
222222
</dependency>
223223
<dependency>
@@ -329,8 +329,8 @@
329329
<inherited>true</inherited>
330330
<artifactId>maven-compiler-plugin</artifactId>
331331
<configuration>
332-
<source>1.8</source>
333-
<target>1.8</target>
332+
<source>1.6</source>
333+
<target>1.6</target>
334334
</configuration>
335335
</plugin>
336336
<plugin>
@@ -369,6 +369,11 @@
369369
</dependency>
370370
</dependencies>
371371
</plugin>
372+
<plugin>
373+
<groupId>org.apache.maven.plugins</groupId>
374+
<artifactId>maven-invoker-plugin</artifactId>
375+
<version>3.0.0</version>
376+
</plugin>
372377
</plugins>
373378
</pluginManagement>
374379
<plugins>

tests/annotations/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target
2+
.project
3+
.classpath
4+
.settings

tests/annox/annotations/pom.xml renamed to tests/annotations/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
<modelVersion>4.0.0</modelVersion>
3535
<parent>
3636
<groupId>org.jvnet.jaxb2_commons</groupId>
37-
<artifactId>jaxb2-annotate-plugin-test-annox</artifactId>
37+
<artifactId>jaxb2-annotate-plugin-tests</artifactId>
3838
<version>1.0.3-SNAPSHOT</version>
3939
<relativePath>../pom.xml</relativePath>
4040
</parent>
41-
<artifactId>jaxb2-annotate-plugin-test-annox-annotations</artifactId>
41+
<artifactId>jaxb2-annotate-plugin-test-annotations</artifactId>
4242
<packaging>jar</packaging>
43-
<name>JAXB2 Annotate Plugin - Test [annox-annotations]</name>
43+
<name>JAXB2 Annotate Plugin - Test [annotations]</name>
4444
</project>
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
* of the authors and should not be interpreted as representing official policies,
2727
* either expressed or implied, of the FreeBSD Project.
2828
*/
29-
/**
30-
*
31-
*/
32-
package org.jvnet.jaxb2_commons.plugin.annotate.test.annox.annotations;
29+
package org.jvnet.jaxb2_commons.plugin.annotate.tests.annotations;
3330

3431
import java.lang.annotation.Retention;
3532
import java.lang.annotation.RetentionPolicy;

0 commit comments

Comments
 (0)