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
17 stars 15 forks source link

Enhance fluent-api to generate single-argument withXYZ() for collection properties #18

Open glassfishrobot opened 15 years ago

glassfishrobot commented 15 years ago

The fluent-api plugin already generates vararg-based withXYZ() methods for collection properties. This works fine in most cases, but when XJC generates properties of type JAXBElement, you end up with a lot of compiler warning when using the vararg method.

This is because JAXBElement is a generic type, and when you pass an object of a generic type to a method with a vararg parameter, the compiler complains:

"a generic array is created for a varargs parameter"

It's a pointless and harmless warning, but you get a lot of them.

I suggest that the fluent-api plugin also generates a with...() method that takes a single, non-vararg parameter, as a special case for the vararg version. This would remove the warnings in cases where we only have a single object to add to the collection.

If this wasn't auto-generated code, I wouldn't see it as worth the bother, but it would many of my bindings less frustrating.

Environment

Operating System: All Platform: All

Affected Versions

[current]

glassfishrobot commented 15 years ago

Reported by skaffman

glassfishrobot commented 15 years ago

Was assigned to hchar

glassfishrobot commented 7 years ago

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