Skip to content

Commit

Permalink
Issue #18.
Browse files Browse the repository at this point in the history
  • Loading branch information
highsource committed Jan 6, 2015
1 parent 1d83c87 commit e3dac6a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class SimplifyPlugin extends AbstractParameterizablePlugin {

private boolean usePluralForm = true;
private boolean usePluralForm = false;

public boolean isUsePluralForm() {
return usePluralForm;
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/simplify-01/src/main/resources/binding.xjb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<simplify:as-element-property />
</simplify:property>
</jaxb:bindings>
<jaxb:bindings node="xs:complexType[@name='gh18']">
<simplify:property name="childOrFootOrFoo">
<simplify:as-element-property />
</simplify:property>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>

11 changes: 11 additions & 0 deletions tests/simplify-01/src/main/resources/schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,15 @@
</xs:annotation>
</xs:element>

<xs:complexType name="gh18">
<xs:sequence>
<xs:element name="a" type="xs:string" />
<xs:choice>
<xs:element name="child" type="xs:dateTime" maxOccurs="unbounded" />
<xs:element name="foot" type="xs:duration" maxOccurs="unbounded" />
<xs:element name="foo" type="xs:int" maxOccurs="unbounded" />
</xs:choice>
</xs:sequence>
</xs:complexType>

</xs:schema>
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e3dac6a

Please sign in to comment.