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

Improve value-constructor plugin to use only elements with minOccurs greater than 0 with no default value and only required attributes #11

Open glassfishrobot opened 16 years ago

glassfishrobot commented 16 years ago

Currently, the value constructor plugin generates a fully initializing constructor with all elements and attributes.

Client codes that use these constructors will break when a new optional element or attribute is added to the schema.

A better solution is to generate a partially initializing constructors with only elements that have minOccurs greater than 0 and with no default value and required attributes.

It'd be better to use the default-value-plugin to provide default values.

Alex Wei

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=3) A patch for the improvement

glassfishrobot commented 16 years ago

ozgwei said: Attached is a patch that allows the combination of 3 different types of constructors: 1) constructor with only mandatory/required elements/attributes with no default value 2) constructor with only mandatory/required elements/attributes 3) the original fully initializing constructor (which can be generated being annotated by @deprecated)

See the test target in the build.xml for usage.

Alex

glassfishrobot commented 16 years ago

File: value-constructor-patch.txt Attached By: ozgwei

glassfishrobot commented 16 years ago

Issue-Links: blocks JAXB2_COMMONS-14

glassfishrobot commented 16 years ago

Was assigned to lexi

glassfishrobot commented 7 years ago

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