jaxb-tools icon indicating copy to clipboard operation
jaxb-tools copied to clipboard

XML Element Wrapper enhancements (keep, etc)

Open mattrpav opened this issue 1 year ago • 4 comments

  • [x] Support lazy instantiation of collection lists in 'replaced' code
  • [x] 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

mattrpav avatar Dec 08 '23 17:12 mattrpav

Support lazy instantiation of collection lists in 'replaced' code

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

laurentschoelens avatar Dec 08 '23 21:12 laurentschoelens

Support deleting unused collection-classes

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

laurentschoelens avatar Dec 08 '23 21:12 laurentschoelens

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

laurentschoelens avatar Dec 08 '23 21:12 laurentschoelens

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: :white_check_mark: List<Item> itemsList = order.getItems() :x: Items itemsWrapper = order.getItems() :x: List<Item> itemsList = itemsWrapper.getItems()

Part 2: :white_check_mark: 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: :white_check_mark: List<Item> itemsList = order.getItems() :white_check_mark: Items itemsWrapper = OrderServce.getOrderItems(String orderId);

mattrpav avatar Feb 15 '24 17:02 mattrpav