Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Element Wrapper enhancements (keep, etc) #463

Open
2 of 3 tasks
mattrpav opened this issue Dec 8, 2023 · 4 comments
Open
2 of 3 tasks

XML Element Wrapper enhancements (keep, etc) #463

mattrpav opened this issue Dec 8, 2023 · 4 comments

Comments

@mattrpav
Copy link
Collaborator

mattrpav commented Dec 8, 2023

  • Support lazy instantiation of collection lists in 'replaced' code
  • Support deleting unused collection-classes
  • Support keeping certain classes when deleting unused collection-classes is enabled (aka 'control' file list of classes and behavior

Sample config from other xew plugins (ref: https://github.com/dmak/jaxb-xew-plugin):

<arg>-Xxew</arg>
<arg>-Xxew:control items-schema.xew</arg>
<arg>-Xxew:instantiate lazy</arg>
<arg>-Xxew:collection java.util.LinkedList</arg>

Schema snippet:

<element name="Items">
  <sequence>
    <element name="Item" type="foo:Item" minOccurs="0" maxOccurs="unbounded"/>
  </sequence>
<element>

Creates:

com.company.Items;
com.company.Item;
  1. When 'control' is enabled, the Items class is deleted
  2. When control file has 'com.company.Items=keep' listed, the class is not deleted
@laurentschoelens
Copy link
Collaborator

laurentschoelens commented Dec 8, 2023

Support lazy instantiation of collection lists in 'replaced' code

Already available with -XelementWrapper:instantiate <EAGER/LAZY> parameter

@laurentschoelens
Copy link
Collaborator

Support deleting unused collection-classes

Same here with this parameter -XelementWrapper:delete (if I understand it well)

@laurentschoelens
Copy link
Collaborator

See documentation of plugin here : https://github.com/highsource/jaxb-tools/wiki/JAXB-XML-ElementWrapper-Plugin

@mattrpav
Copy link
Collaborator Author

mattrpav commented Feb 15, 2024

xew key features:

Part 1. Remove inner collection wrapper-only classes (ie. 'items')
Part 2. Delete unused wrapper-only classes

Use cases for 'keep' (ie sometimes do not do part 2):

[Scenario 1] Remove collection-only wrapper object (double wrapper) and delete unused wrapper-only class

Part 1:
✅ List itemsList = order.getItems()
❌ Items itemsWrapper = order.getItems()
❌ List itemsList = itemsWrapper.getItems()

Part 2:
✅ Delete the Items class

[Scenario 2] 'keep' the wrapper-only object for this when we need a 'wrapper' for SOAP/REST return payload
Part 1, but not Part 2:
✅ List itemsList = order.getItems()
✅ Items itemsWrapper = OrderServce.getOrderItems(String orderId);

@mattrpav mattrpav changed the title XML Element Wrapper enhancements XML Element Wrapper enhancements (keep, etc) Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants