Expanders 5.33.0
· 2 min read
This version of the expanders introduces improved support for imports in Expanders.
Pruned Imports
This version includes a cleanup of several of the unused imports in Expanders. It is possible you may need to add imports for classes you use in custom code after upgrading.
Resources
The expansion resources below provide Expanders 5.33.2
.
Resource | Version |
---|---|
Expanders | 5.33.2 |
nsx-default-stack | 2023.16.4 |
Changes and improvements
Better support of Imports in mapping files
The mapping file syntax has been extended with 2 new keywords: artifact
and uses
.
Mapping files often had a separate list
statement to resolve imports:
FinderDetailsExpanderMapping.xml
<mapping xmlns="https://schemas.normalizedsystems.org/xsd/expanders/2023/0/0/mapping">
<list name="valueTypes"
eval="finder.fieldOperatorPairs.{ field }.{? valueField neq null }.{ javaType }"
param="javaType" unique="javaType">
<filter name="requiresImport" eval="javaType.requiresImport()"/>
<value name="qualifiedType" eval="javaType.qualifiedTypeName"/>
</list>
<list name="fields" eval="finder.fieldOperatorPairs"
param="fieldOperatorPair" filter="fieldOperatorPair.field neq null">
<let name="field" eval="fieldOperatorPair.field"/>
<value name="name" eval="field.name"/>
<!-- ... -->
</list>
<!-- ... -->
</mapping>
This can be replaced by adding uses
statements for the imported classes. The artifact
definition describes which
import resolver to use.
FinderDetailsExpanderMapping.xml
<mapping xmlns="https://schemas.normalizedsystems.org/xsd/expanders/2023/1/0/mapping">
<artifact this="classBuilder.from(finder).qualifiedName + 'Details'" importStrategy="java"/>
<list name="fields" eval="finder.fieldOperatorPairs"
param="fieldOperatorPair" filter="fieldOperatorPair.field neq null">
<let name="field" eval="fieldOperatorPair.field"/>
<value name="name" eval="field.name"/>
<uses eval="field.javaType"/>
<!-- ... -->
</list>
<!-- ... -->
</mapping>
The imports can then be inserted into the template with @imports
:
FinderDetailsExpander.stg
base() ::= <<
package <dataElement.type.packageName>;
// <expanderComment>
// anchor:imports:start
@imports
// anchor:imports:end
@anchor:imports
...
>>
Check out the article to learn more.