Skip to content

Commit e3dac6a

Browse files
committed
Issue #18.
1 parent 1d83c87 commit e3dac6a

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
public class SimplifyPlugin extends AbstractParameterizablePlugin {
3636

37-
private boolean usePluralForm = true;
37+
private boolean usePluralForm = false;
3838

3939
public boolean isUsePluralForm() {
4040
return usePluralForm;
@@ -358,15 +358,15 @@ private String createPropertyName(final Model model,
358358
localPart = element.getElementName().getLocalPart();
359359
}
360360
final String propertyName = model.getNameConverter().toPropertyName(
361-
localPart);
362-
return pluralizeIfNecessary(propertyInfo, propertyName);
361+
pluralizeIfNecessary(propertyInfo, localPart));
362+
return propertyName;
363363
}
364364

365365
private String createPropertyName(final Model model,
366366
CPropertyInfo propertyInfo, CTypeRef element) {
367367
final String propertyName = model.getNameConverter().toPropertyName(
368-
element.getTagName().getLocalPart());
369-
return pluralizeIfNecessary(propertyInfo, propertyName);
368+
pluralizeIfNecessary(propertyInfo, element.getTagName().getLocalPart()));
369+
return propertyName;
370370
}
371371

372372
private String pluralizeIfNecessary(CPropertyInfo propertyInfo,

tests/simplify-01/src/main/resources/binding.xjb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<simplify:as-element-property />
1818
</simplify:property>
1919
</jaxb:bindings>
20+
<jaxb:bindings node="xs:complexType[@name='gh18']">
21+
<simplify:property name="childOrFootOrFoo">
22+
<simplify:as-element-property />
23+
</simplify:property>
24+
</jaxb:bindings>
2025
</jaxb:bindings>
2126
</jaxb:bindings>
2227

tests/simplify-01/src/main/resources/schema.xsd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,15 @@
101101
</xs:annotation>
102102
</xs:element>
103103

104+
<xs:complexType name="gh18">
105+
<xs:sequence>
106+
<xs:element name="a" type="xs:string" />
107+
<xs:choice>
108+
<xs:element name="child" type="xs:dateTime" maxOccurs="unbounded" />
109+
<xs:element name="foot" type="xs:duration" maxOccurs="unbounded" />
110+
<xs:element name="foo" type="xs:int" maxOccurs="unbounded" />
111+
</xs:choice>
112+
</xs:sequence>
113+
</xs:complexType>
114+
104115
</xs:schema>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.jvnet.jaxb2_commons.plugin.simplify.tests01;
2+
3+
import org.junit.Test;
4+
5+
public class Gh18Test {
6+
7+
@Test
8+
public void compiles() {
9+
final Gh18 item = new Gh18();
10+
item.getA();
11+
item.getChildren();
12+
item.getFeet();
13+
item.getFoos();
14+
}
15+
}

tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/Gh1Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class Gh1Test {
1616
public void compiles()
1717
{
1818
final Gh1 item = new Gh1();
19-
item.getAS();
20-
item.getBS();
19+
item.getAs();
20+
item.getBs();
2121
item.getMixedContent();
2222

2323
}
@@ -26,8 +26,8 @@ public void compiles()
2626
public void contextIsSuccessfullyCreated() throws JAXBException {
2727
final JAXBContext context = JAXBContext.newInstance(Gh1.class);
2828
final Gh1 value = new Gh1();
29-
value.getAS().add("a");
30-
value.getBS().add(2);
29+
value.getAs().add("a");
30+
value.getBs().add(2);
3131
value.getMixedContent().add("Test");
3232

3333
final StringWriter sw = new StringWriter();

tests/simplify-01/src/test/java/org/jvnet/jaxb2_commons/plugin/simplify/tests01/RunSimplifyPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void compilesSchema() throws Exception {
2828
URL binding = getClass().getResource("/binding.xjb");
2929
final String[] arguments = new String[] { "-xmlschema",
3030
schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
31-
"target/generated-sources/xjc", "-extension", "-Xsimplify"};
31+
"target/generated-sources/xjc", "-extension", "-Xsimplify", "-Xsimplify-usePluralForm=true"};
3232

3333
Options options = new Options();
3434
options.parseArguments(arguments);

0 commit comments

Comments
 (0)