Skip to content

Conversation

@dfcoffin
Copy link
Contributor

@dfcoffin dfcoffin commented Jan 6, 2026

Summary

Completes Issue #61 by converting the remaining 2 DTO POJOs (TimeConfigurationDto and UsagePointDto) to Java records, achieving 100% record adoption across all 36 DTOs.

Changes Made

Core DTO Conversions

  • TimeConfigurationDto: Converted from POJO class to record with @XmlAccessorType(FIELD)
  • UsagePointDto: Converted from POJO class to record with @XmlAccessorType(FIELD)
  • Moved JAXB annotations from getter methods to record component parameters
  • Added defensive byte array cloning in overridden accessors (dstStartRule(), dstEndRule(), roleFlags())
  • Eliminated @XmlTransient annotations on utility methods (no longer needed with FIELD access)

Atom Feed Namespace Support

  • AtomEntryDto: Enhanced to dynamically add xmlns:espi and xmlns:cust namespace declarations
  • Auto-computes appropriate namespace based on resource type (usage vs customer)
  • Supports both ESPI usage namespace (http://naesb.org/espi) and customer namespace (http://naesb.org/espi/customer)

ESPI Resource Type Mappings

  • @JsonSubTypes: Expanded to include all 17 ESPI resources:
    • 9 Usage resources: ApplicationInformation, Authorization, ElectricPowerQualitySummary, IntervalBlock, MeterReading, ReadingType, TimeConfiguration, UsagePoint, UsageSummary
    • 8 Customer resources: Customer, CustomerAccount, CustomerAgreement, EndDevice, Meter, ProgramDateIdMappings, ServiceLocation, Statement
    • Note: TimeConfigurationDto supports BOTH espi:TimeConfiguration and cust:TimeConfiguration namespaces

Test Updates

  • Updated test assertions to accommodate namespace attributes in entry elements
  • Fixed accessor method syntax (getter methods → record accessors)

Benefits

  • 100% Record Adoption: All 36 DTOs now use consistent record pattern
  • Code Reduction: Eliminated 141 lines of boilerplate code (341 insertions, 482 deletions)
  • Improved Maintainability: Simplified namespace handling with auto-computed attributes
  • Full Compatibility: Maintains Jackson 3 XmlMapper and ESPI 4.0 compliance

Testing

All tests passing (554/554)

  • TimeConfigurationDtoTest: 11/11 tests
  • Jackson3XmlMarshallingTest: 7/7 tests
  • DtoExportServiceImplTest: 6/6 tests
  • Full test suite: No regressions

Files Changed

  • AtomEntryDto.java - Added dynamic namespace support
  • TimeConfigurationDto.java - Converted to record
  • UsagePointDto.java - Converted to record
  • TimeConfigurationDtoTest.java - Updated test assertions
  • Jackson3XmlMarshallingTest.java - Updated test assertions
  • DtoExportServiceImplTest.java - Updated test assertions

🤖 Generated with Claude Code

…ith FIELD access

Completes Issue #61 - Convert remaining DTO POJOs to Java records for improved
immutability and cleaner code.

Changes:
- Converted TimeConfigurationDto from POJO class to record with @XmlAccessType(FIELD)
- Converted UsagePointDto from POJO class to record with @XmlAccessType(FIELD)
- Moved JAXB annotations from getter methods to record component parameters
- Added defensive byte array cloning in overridden accessors
- Eliminated @XmlTransient annotations on utility methods (no longer needed with FIELD access)
- Updated AtomEntryDto to dynamically add xmlns:espi and xmlns:cust namespace declarations
- Enhanced @JsonSubTypes to include all 17 ESPI resources (9 usage + 8 customer)
- Updated test assertions to accommodate namespace attributes in entry elements

Benefits:
- All 36 DTOs now use consistent record pattern (100% adoption)
- Reduced code from 355 lines by eliminating boilerplate
- Simplified namespace handling with auto-computed attributes
- Maintains full Jackson 3 XmlMapper compatibility
- All 554 tests passing with no regressions

Testing:
- TimeConfigurationDtoTest: 11/11 tests passing
- Jackson3XmlMarshallingTest: 7/7 tests passing
- DtoExportServiceImplTest: 6/6 tests passing
- Full test suite: 554/554 tests passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dfcoffin dfcoffin merged commit e48ab3e into main Jan 6, 2026
5 checks passed
@dfcoffin dfcoffin deleted the feature/convert-dto-pojos-to-records branch January 6, 2026 22:55
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.

2 participants