From e3dac6a04dba62e28c257420acc658fe1d2a0e01 Mon Sep 17 00:00:00 2001 From: highsource Date: Tue, 6 Jan 2015 20:37:10 +0100 Subject: [PATCH] Issue #18. --- .../plugin/simplify/SimplifyPlugin.java | 10 +++++----- tests/simplify-01/src/main/resources/binding.xjb | 5 +++++ tests/simplify-01/src/main/resources/schema.xsd | 11 +++++++++++ .../plugin/simplify/tests01/Gh18Test.java | 15 +++++++++++++++ .../plugin/simplify/tests01/Gh1Test.java | 8 ++++---- .../simplify/tests01/RunSimplifyPlugin.java | 2 +- 6 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh18Test.java diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java index 75a2472a..208e0585 100644 --- a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java +++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java @@ -34,7 +34,7 @@ public class SimplifyPlugin extends AbstractParameterizablePlugin { - private boolean usePluralForm = true; + private boolean usePluralForm = false; public boolean isUsePluralForm() { return usePluralForm; @@ -358,15 +358,15 @@ private String createPropertyName(final Model model, localPart = element.getElementName().getLocalPart(); } final String propertyName = model.getNameConverter().toPropertyName( - localPart); - return pluralizeIfNecessary(propertyInfo, propertyName); + pluralizeIfNecessary(propertyInfo, localPart)); + return propertyName; } private String createPropertyName(final Model model, CPropertyInfo propertyInfo, CTypeRef element) { final String propertyName = model.getNameConverter().toPropertyName( - element.getTagName().getLocalPart()); - return pluralizeIfNecessary(propertyInfo, propertyName); + pluralizeIfNecessary(propertyInfo, element.getTagName().getLocalPart())); + return propertyName; } private String pluralizeIfNecessary(CPropertyInfo propertyInfo, diff --git a/tests/simplify-01/src/main/resources/binding.xjb b/tests/simplify-01/src/main/resources/binding.xjb index c78d2d52..53b5f124 100644 --- a/tests/simplify-01/src/main/resources/binding.xjb +++ b/tests/simplify-01/src/main/resources/binding.xjb @@ -17,6 +17,11 @@ + + + + + diff --git a/tests/simplify-01/src/main/resources/schema.xsd b/tests/simplify-01/src/main/resources/schema.xsd index 72e85c8f..7d2f0e96 100644 --- a/tests/simplify-01/src/main/resources/schema.xsd +++ b/tests/simplify-01/src/main/resources/schema.xsd @@ -101,4 +101,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh18Test.java b/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh18Test.java new file mode 100644 index 00000000..877c812e --- /dev/null +++ b/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh18Test.java @@ -0,0 +1,15 @@ +package org.jvnet.jaxb2_commons.plugin.simplify.tests01; + +import org.junit.Test; + +public class Gh18Test { + + @Test + public void compiles() { + final Gh18 item = new Gh18(); + item.getA(); + item.getChildren(); + item.getFeet(); + item.getFoos(); + } +} diff --git a/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh1Test.java b/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh1Test.java index c8065d95..e4560411 100644 --- a/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh1Test.java +++ b/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh1Test.java @@ -16,8 +16,8 @@ public class Gh1Test { public void compiles() { final Gh1 item = new Gh1(); - item.getAS(); - item.getBS(); + item.getAs(); + item.getBs(); item.getMixedContent(); } @@ -26,8 +26,8 @@ public void compiles() public void contextIsSuccessfullyCreated() throws JAXBException { final JAXBContext context = JAXBContext.newInstance(Gh1.class); final Gh1 value = new Gh1(); - value.getAS().add("a"); - value.getBS().add(2); + value.getAs().add("a"); + value.getBs().add(2); value.getMixedContent().add("Test"); final StringWriter sw = new StringWriter(); diff --git a/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/RunSimplifyPlugin.java b/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/RunSimplifyPlugin.java index 23d3be7c..7dec7d28 100644 --- a/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/RunSimplifyPlugin.java +++ b/tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/RunSimplifyPlugin.java @@ -28,7 +28,7 @@ public void compilesSchema() throws Exception { URL binding = getClass().getResource("/binding.xjb"); final String[] arguments = new String[] { "-xmlschema", schema.toExternalForm(), "-b", binding.toExternalForm(), "-d", - "target/generated-sources/xjc", "-extension", "-Xsimplify"}; + "target/generated-sources/xjc", "-extension", "-Xsimplify", "-Xsimplify-usePluralForm=true"}; Options options = new Options(); options.parseArguments(arguments);