Feat: DataPatching: Map collection elements: Set/List elements. - #14252
Feat: DataPatching: Map collection elements: Set/List elements.#14252Pa-Touche wants to merge 2 commits into
Conversation
Supports all types supported by the ValueMapperRegistry.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCollection-valued patching now supports ChangesCollection patching
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant DataPatcherImpl
participant PropertyAccessor
participant ValueMapperRegistry
participant CollectionPatchMapper
DataPatcherImpl->>PropertyAccessor: resolve collection element type
DataPatcherImpl->>ValueMapperRegistry: submit collection patch request
ValueMapperRegistry->>CollectionPatchMapper: map collection string
CollectionPatchMapper->>ValueMapperRegistry: map each element
ValueMapperRegistry-->>CollectionPatchMapper: return element result
CollectionPatchMapper-->>DataPatcherImpl: return Set or List
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
sormas-api/src/main/java/de/symeda/sormas/api/patch/mapping/ValuePatchRequest.java (1)
22-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
collectionSubTypetyped asClass<T>is type-unsound; should beClass<?>.
collectionSubTyperepresents the element type inside the collection identified bytargetType, not the collection type itself, so it shouldn't share the same generic parameterT. With proper (non-raw) generics this wouldn't even compile — e.g.new ValuePatchRequest<Set>().setTargetType(Set.class).setCollectionSubType(ExposureSubSetting.class)fails becauseExposureSubSetting.classisClass<ExposureSubSetting>, notClass<Set>.This is why every consumer (
DataPatcherImpl#valueMappingResult,CollectionPatchMapper#buildRequestFrom) and every new test is forced to useValuePatchRequestas a raw type with@SuppressWarnings({"unchecked","rawtypes"})— a direct symptom of this API's generics being unsound rather than a coincidence.♻️ Proposed fix
- `@Nullable` - private Class<T> collectionSubType; + `@Nullable` + private Class<?> collectionSubType;- `@Nullable` - public Class<T> getCollectionSubType() { - return collectionSubType; - } - - public ValuePatchRequest<T> setCollectionSubType(`@Nullable` Class<T> collectionSubType) { + `@Nullable` + public Class<?> getCollectionSubType() { + return collectionSubType; + } + + public ValuePatchRequest<T> setCollectionSubType(`@Nullable` Class<?> collectionSubType) { this.collectionSubType = collectionSubType; return this; }Also applies to: 59-68
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sormas-api/src/main/java/de/symeda/sormas/api/patch/mapping/ValuePatchRequest.java` around lines 22 - 28, Change ValuePatchRequest.collectionSubType from Class<T> to Class<?> because it represents the collection element type rather than the request’s target type parameter. Update its getter, setter, and all consumers including DataPatcherImpl#valueMappingResult and CollectionPatchMapper#buildRequestFrom to use the corrected wildcard type, then remove raw ValuePatchRequest usage and related unchecked/raw suppressions where no longer needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/patch/mapping/ValueMapperRegistry.java`:
- Around line 59-68: Update the collection validation in ValueMapperRegistry to
evaluate every element with request.getCollectionSubType().isInstance rather
than sampling via findAny() or comparing exact classes. Preserve the existing
invalid-type result when any element is incompatible, while allowing empty
collections through the allMatch behavior.
---
Nitpick comments:
In
`@sormas-api/src/main/java/de/symeda/sormas/api/patch/mapping/ValuePatchRequest.java`:
- Around line 22-28: Change ValuePatchRequest.collectionSubType from Class<T> to
Class<?> because it represents the collection element type rather than the
request’s target type parameter. Update its getter, setter, and all consumers
including DataPatcherImpl#valueMappingResult and
CollectionPatchMapper#buildRequestFrom to use the corrected wildcard type, then
remove raw ValuePatchRequest usage and related unchecked/raw suppressions where
no longer needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9b41c79b-ff9b-4508-a2c7-55d501bd4374
📒 Files selected for processing (10)
sormas-api/src/main/java/de/symeda/sormas/api/patch/mapping/ValuePatchRequest.javasormas-backend/src/main/java/de/symeda/sormas/backend/patch/DataPatcherImpl.javasormas-backend/src/main/java/de/symeda/sormas/backend/patch/PropertyAccessor.javasormas-backend/src/main/java/de/symeda/sormas/backend/patch/mapping/ValueMapperRegistry.javasormas-backend/src/main/java/de/symeda/sormas/backend/patch/mapping/impl/valuemapper/CollectionPatchMapper.javasormas-backend/src/test/java/de/symeda/sormas/backend/AbstractBeanTest.javasormas-backend/src/test/java/de/symeda/sormas/backend/patch/PropertyAccessorTest.javasormas-backend/src/test/java/de/symeda/sormas/backend/patch/mapping/ValueMapperRegistryTest.javasormas-backend/src/test/java/de/symeda/sormas/backend/patch/mapping/impl/valuemapper/CollectionPatchMapperTest.javasormas-backend/src/test/java/de/symeda/sormas/patch/DataPatcherImplTest.java
💤 Files with no reviewable changes (1)
- sormas-backend/src/test/java/de/symeda/sormas/backend/AbstractBeanTest.java
Supports all types supported by the ValueMapperRegistry.
Fixes #14251
Summary by CodeRabbit
New Features
Tests