javaee / jaxb2-commons

JAXB Implementation project has been contributed to Eclipse Foundation. This repository is for legacy review only. Please refer to the Eclipse EE4J Metro project for the very latest
https://eclipse-ee4j.github.io/jaxb-ri/
Other
16 stars 15 forks source link

Improve fluent-api to accept a Collection for elements with maxOccurs > 1 in addition to the original varargs parameter #12

Closed glassfishrobot closed 16 years ago

glassfishrobot commented 16 years ago

Currently when an element has maxOccurs > 1, the fluent-api plugin generates a withXxx method that accepts a vararg, such as: public TypeA withXxx(String... values) { if (values != null) { for (String value : values)

{ getXxx().add(value); }

} return this; }

This can be inconvenient if you happen to have a Collection instead of an array or predefined inputs.

Often I have to call like this: new TypeA() .withXxx((String[])xxxList.toArray(new String[xxxList.size()]));

So I propose an improvement to overload this method to accept a Collection as well: public TypeA withXxx(Collection xxx) { if (xxx != null)

{ getXxx().addAll(xxx); }

return this; }

Cheers, Alex

Environment

Operating System: All Platform: All

Affected Versions

[current]

glassfishrobot commented 16 years ago

Reported by ozgwei

glassfishrobot commented 16 years ago

ozgwei said: Created an attachment (id=4) A patch for the improvement

glassfishrobot commented 16 years ago

hchar said: reassigned to the owner of the fluent api plugin

glassfishrobot commented 16 years ago

hchar said: ditto

glassfishrobot commented 16 years ago

hchar said: Looking into this. Thanks for the suggestion and patch!

glassfishrobot commented 16 years ago

hchar said: Some minor modification and checked in the code changes to CVS. Will arrange a release later on.

glassfishrobot commented 16 years ago

hchar said: 2.1.8 released.

glassfishrobot commented 16 years ago

File: fluent-api-patch.txt Attached By: ozgwei

glassfishrobot commented 16 years ago

Was assigned to hchar

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB2_COMMONS-12

glassfishrobot commented 16 years ago

Marked as fixed on Sunday, October 12th 2008, 2:15:40 am