Skip to content

Extend code generator to support complex interface patterns in databind bindings #572

@david-waltermire

Description

@david-waltermire

Summary

The databind module contains pre-generated binding classes in gov.nist.secauto.metaschema.databind.model.metaschema.binding that have been heavily modified with:

  • Custom interface implementations
  • Extended base classes
  • Additional helper methods

These modifications are defined in the binding configuration (databind-metaschema/src/main/metaschema-bindings/metaschema-metaschema-bindings.xml) but the current code generator doesn't fully support regenerating these classes with all customizations intact.

Current State

  • Binding classes are pre-generated and checked into src/main/java
  • Manual modifications have been applied post-generation
  • No automated way to regenerate while preserving customizations
  • Collection properties use hardcoded implementation classes (LinkedList, LinkedHashMap)

Proposed Solution

Extend the metaschema-maven-plugin code generator to support:

1. Interface and Base Class Configuration

  • <implement-interface> - Add interface implementations to generated classes
  • <extend-base-class> - Specify custom base classes

2. Collection Implementation Override

Support overriding the default collection implementation class for collection-typed properties via binding configuration:

<define-assembly name="test-suite">
  <define-field name="test-collections">
    <collection-class>java.util.ArrayList</collection-class>
  </define-field>
</define-assembly>

This allows:

  • ArrayList instead of LinkedList for better random access performance
  • TreeMap instead of LinkedHashMap for sorted key ordering
  • Custom collection implementations for specialized use cases

The generator should:

  1. Parse the <collection-class> element from binding configuration
  2. Pass the override to getCollectionImplementationClass() in the type info
  3. Fall back to current defaults (LinkedList/LinkedHashMap) when not specified
  4. Validate that the specified class is compatible with the collection type (List vs Map)

Acceptance Criteria

  • Code generator supports implement-interface binding configuration
  • Code generator supports extend-base-class binding configuration
  • Code generator supports collection-class binding configuration for collection properties
  • Collection class override is validated for type compatibility (List/Map)
  • Regenerated databind binding classes match current functionality
  • Add pom-bootstrap.xml for databind module
  • Document bootstrap process in databind README

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions