Skip to content

chore: address Eclipse warnings and improve null safety#605

Merged
david-waltermire merged 1 commit intometaschema-framework:developfrom
david-waltermire:cleanup/manual-fixes
Dec 31, 2025
Merged

chore: address Eclipse warnings and improve null safety#605
david-waltermire merged 1 commit intometaschema-framework:developfrom
david-waltermire:cleanup/manual-fixes

Conversation

@david-waltermire
Copy link
Contributor

@david-waltermire david-waltermire commented Dec 30, 2025

Summary

This PR addresses Eclipse IDE warnings across all modules, improves null safety throughout the codebase, and enhances the code generator with better validation and diagnostics.

Changes

CLI Processor Module

  • CallingContext.java: Wrap Optional.of() and Optional.empty() returns with ObjectUtils.notNull()
  • ShellCompletionCommand.java: Wrap List.get() and Path.of() returns for null safety
  • CompletionScriptGenerator.java: Wrap StringBuilder.toString() and String.replaceAll() returns
  • CompletionTypeRegistry.java: Wrap Collectors.joining() result

Core Module

  • DynamicContext.java: Remove unused imports
  • JsonPointerFormatter.java: Remove unused imports
  • NodeItemTraversalTest.java: Wrap URI.create() calls with ObjectUtils.notNull()
  • Various test files: Add assertNotNull checks and remove unused imports

Databind Module

Code Generator Enhancements

  • AbstractPropertyTypeInfo.java:
    • Add introspection to detect methods declared in superinterfaces
    • Generate @Override annotations for getters/setters that override interface methods
    • Check base class and superinterfaces via reflection
  • DefaultMetaschemaClassFactory.java:
    • Add extendsIBoundObject() helper to check if interfaces extend IBoundObject
    • Omit redundant IBoundObject interface when a superinterface already extends it
  • DefaultBindingConfiguration.java:
    • Restore null check for groupAsName (fixes NPE with ConcurrentHashMap)
    • Add logging warnings for bindings missing both name and target attributes
    • Add descriptive error messages to Objects.requireNonNull() calls
  • ClassUtils.java: Remove redundant assert on caught exception
  • ChoiceGroupTypeInfoImpl.java: Add null-safe Javadoc generation for item types

Binding Model Improvements

  • InstanceModelGroupedFieldInline.java: Add null check for flagName before IEnhancedQName.of()
  • Generated binding classes: Wrap collection and toString returns with ObjectUtils.notNull()

Schemagen Module

  • IXmlGenerationState.java: New interface to break circular dependency
  • XmlDatatypeManager.java: Add public constants for XML Schema namespace/prefix
  • XmlGenerationState.java: Implement new interface
  • Update type generation classes to use interface instead of concrete class

Eclipse Configuration

  • Disable annotation processing (aptEnabled=false) across all modules
  • Update .gitignore to include Eclipse JDT APT preferences

Documentation

  • Add "Classpath Requirements for Code Generation" section to .claude/skills/metaschema-java-library.md:
    • How the generator uses reflection for method override detection
    • Maven plugin dependency configuration example
    • Behavior when classes aren't on classpath during code generation
    • Multi-module project considerations

Review Feedback Addressed

  1. DefaultBindingConfiguration.java:

    • Restore null check for groupAsName (NPE prevention)
    • Replace assert with Objects.requireNonNull() for interface names
    • Add descriptive error messages for null checks
    • Add logging warnings for skipped bindings
  2. InstanceModelGroupedFieldInline.java:

    • Add null check for flagName before IEnhancedQName.of() call
  3. BoundChoiceTest.java:

    • Move assertNotNull outside lambda for clearer error messages

Test plan

  • All tests pass with mvn test
  • Build succeeds with mvn install -PCI -Prelease
  • Eclipse warnings resolved

Summary by CodeRabbit

  • Refactor

    • Improved null-safety and resource/ownership handling across the project for more robust runtime and test behavior.
  • New Features

    • Added public helper APIs and utilities to simplify schema/code generation, databind operations, and test support.
  • Documentation

    • Extensive Javadoc, package docs, and docs updates; new PRD entries added (one completed, one in progress).
  • Chores

    • Standardized IDE/formatter preferences and updated ignore rules to include a previously excluded IDE prefs file.

✏️ Tip: You can customize this high-level summary in your review settings.

Loading
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

Successfully merging this pull request may close these issues.

1 participant