You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Convert TimeConfigurationDto and UsagePointDto to records with FIELD access (#65)
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 <[email protected]>
@Schema(description = "Internal DTO identifier (not serialized to XML)")
50
+
Longid,
51
+
52
+
@XmlTransient
53
+
@Schema(description = "Resource identifier (mRID)", example = "550e8400-e29b-41d4-a716-446655440000")
54
+
Stringuuid,
55
+
56
+
@XmlElement(name = "dstEndRule", type = String.class)
57
+
@XmlJavaTypeAdapter(HexBinaryAdapter.class)
58
+
@Schema(description = "Rule to calculate end of daylight savings time in the current year. Result of dstEndRule must be greater than result of dstStartRule.", example = "...")
59
+
byte[] dstEndRule,
60
+
61
+
@XmlElement(name = "dstOffset")
62
+
@Schema(description = "Daylight savings time offset from local standard time in seconds", example = "3600")
63
+
LongdstOffset,
64
+
65
+
@XmlElement(name = "dstStartRule", type = String.class)
66
+
@XmlJavaTypeAdapter(HexBinaryAdapter.class)
67
+
@Schema(description = "Rule to calculate start of daylight savings time in the current year. Result of dstEndRule must be greater than result of dstStartRule.", example = "...")
68
+
byte[] dstStartRule,
69
+
70
+
@XmlElement(name = "tzOffset")
71
+
@Schema(description = "Local time zone offset from UTC in seconds. Does not include any daylight savings time offsets. Positive values are east of UTC, negative values are west of UTC.", example = "-28800")
72
+
LongtzOffset
48
73
49
-
privateLongid;
50
-
privateStringuuid;
51
-
privatebyte[] dstEndRule;
52
-
privateLongdstOffset;
53
-
privatebyte[] dstStartRule;
54
-
privateLongtzOffset;
74
+
) {
55
75
56
76
/**
57
77
* Default constructor for JAXB.
58
78
*/
59
79
publicTimeConfigurationDto() {
80
+
this(null, null, null, null, null, null);
60
81
}
61
82
62
83
/**
@@ -65,7 +86,7 @@ public TimeConfigurationDto() {
65
86
* @param tzOffset the timezone offset in seconds from UTC
66
87
*/
67
88
publicTimeConfigurationDto(LongtzOffset) {
68
-
this.tzOffset = tzOffset;
89
+
this(null, null, null, null, null, tzOffset);
69
90
}
70
91
71
92
/**
@@ -75,104 +96,36 @@ public TimeConfigurationDto(Long tzOffset) {
75
96
* @param tzOffset the timezone offset in seconds from UTC
@Schema(description = "Rule to calculate end of daylight savings time in the current year. Result of dstEndRule must be greater than result of dstStartRule.", example = "...")
@Schema(description = "Rule to calculate start of daylight savings time in the current year. Result of dstEndRule must be greater than result of dstStartRule.", example = "...")
130
-
publicbyte[] getDstStartRule() {
112
+
/**
113
+
* Override dstStartRule getter to return cloned array for defensive copying.
@Schema(description = "Local time zone offset from UTC in seconds. Does not include any daylight savings time offsets. Positive values are east of UTC, negative values are west of UTC.", example = "-28800")
0 commit comments