refactor(search): convert ContentletSearch to immutable interface#35661
refactor(search): convert ContentletSearch to immutable interface#35661fabrizzio-dotCMS wants to merge 3 commits into
Conversation
Replaces the mutable POJO with an @Value.Immutable interface backed by ImmutableContentletSearch, eliminating all setters and enforcing construction-time initialization via the builder. All 25 call sites migrated: instantiation uses ImmutableContentletSearch.builder(), getters renamed from getXxx() to bare accessor style (inode(), identifier(), id(), index(), score()) per Immutables convention. Relates to #35609 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ntletSearch Restores getInode(), getIdentifier(), getId(), getIndex(), getScore() method names on the ContentletSearch interface. The bare accessor style (inode(), identifier()…) touched too many unrelated call sites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @fabrizzio-dotCMS's task in 2m 33s —— View job PR Review: ContentletSearch immutable conversion
Clean refactor overall. Mechanics are sound and all 25 call sites are consistently migrated. A few items worth a second look: 1. PR description is stale (cosmetic, but misleading) The description claims bare accessor style ( 2. Semantic change: equals/hashCode is now field-based, not identity-based The old class had default I searched for 3. Old: No callers parse this string, and grep didn't surface log assertions depending on it. Cosmetic regression for anyone reading logs; not blocking. 4. Nullable string At 5. Old 6. Field order in builder is fine but inconsistent with old write order In TL;DR: Code change is low-risk and well-executed. Update the PR description to reflect the actual accessor style and to call out the equals/hashCode semantic change. No blocking issues. |
|
Pull Request Unsafe to Rollback!!!
🤖 Generated with Claude Code - View job run |
Summary
Converts
ContentletSearchfrom a mutable POJO into a@Value.Immutableinterface backed byImmutableContentletSearch, eliminating all setters and enforcing construction-time initialization. All 6 instantiation sites are migrated to the builder pattern. ExistinggetXxx()accessors are preserved unchanged, so the ~35 read-only call sites require no modifications.Changes
Backend — model
ContentletSearchrewritten as@Value.Immutableinterface; removes all 5 setters (setId,setInode,setIdentifier,setIndex,setScore)@Nullable;getScore()annotated@Value.Default(returns0.0f) to preserve the original primitive defaultBackend — instantiation sites (6 files)
ESSearchAPIImpl—new ContentletSearch()+setInode→ImmutableContentletSearch.builder().inode(...).build()ESContentletAPIImpl— full 5-field builderESContentletScrollImpl— full 5-field builderOSContentletScrollImpl— full 5-field builderContentUtils— 2-field builder (inode+identifier)PaginatedContentletsIntegrationTest— test helper migrated to builderTesting
./mvnw install -pl :dotcms-core -DskipTests— compiles cleanPaginatedContentletsIntegrationTestupdated to use the builderTo verify locally:
./mvnw install -pl :dotcms-core -DskipTests— should produce no errorsnew ContentletSearch()in the codebase — should return zero resultsBreaking Changes
new ContentletSearch()and allsetXxx()calls are no longer valid. Any OSGi plugin or external code that instantiatesContentletSearchdirectly must migrate toImmutableContentletSearch.builder(). All known sites within this repo are updated in this PR.Relates to #35609
🤖 Generated with Claude Code