Skip to content

feat(collections,clustering): complete Kotlin migration for core modules and apply optimizations - #1766

Open
dkhawk wants to merge 1 commit into
mainfrom
chore/lint-fixes
Open

feat(collections,clustering): complete Kotlin migration for core modules and apply optimizations#1766
dkhawk wants to merge 1 commit into
mainfrom
chore/lint-fixes

Conversation

@dkhawk

@dkhawk dkhawk commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  1. Complete Kotlin Migration for Core Library Modules & Tests: Converted all remaining Java source files across :library and :data to idiomatic, safe Kotlin (KmlUrlSanitizer, MapObjectManager, MarkerManager, CircleManager, GroundOverlayManager, PolygonManager, PolylineManager, KmlZipBombTest, StaticClusterTest).
  2. Comprehensive Unit Test Suites with Google Truth: Added robust, literate-programming unit tests covering previously untested collection managers, algorithm adapters, projections, and ClusterManager lifecycle operations (MapObjectManagerTest, MarkerManagerTest, CircleManagerTest, GroundOverlayManagerTest, PolygonManagerTest, PolylineManagerTest, NonHierarchicalViewBasedAlgorithmTest, ScreenBasedAlgorithmAdapterTest, GridBasedAlgorithmTest, AbstractAlgorithmTest, SphericalMercatorProjectionTest, StaticClusterTest, ClusterManagerTest).
  3. Clean Kotlin Idioms & Optimizations:
    • Replaced !! force-unwraps with safe checks and .also { ... }.
    • Replaced escaped keyword parameters (`object`) with descriptive parameter names.
    • Replaced java.util collection instantiations with pure Kotlin collection builders (mutableMapOf(), mutableSetOf()).
    • Simplified delegating methods to concise single-line expression bodies (=).
    • Optimized loops in HeatmapTileProvider.kt raster calculations.
    • Removed redundant open modality modifiers in ClusterManager.kt.

Verification

./gradlew test lint assemble jacocoTestDebugUnitTestReport — all 265 test tasks, lint checks, and coverage reports succeeded (88.28% coverage on :library, 30.53% on :clustering).

Reviewer

cc @LoyalAbbas

@dkhawk dkhawk changed the title chore: apply upstream lint fixes, modality cleanup, and forEach refactoring feat(collections,clustering): complete Kotlin migration for core modules and apply optimizations Aug 26, 2026
@googlemaps-bot

googlemaps-bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 50.4% -0.48% 🍏
Files changed 81.52% 🍏

Module Coverage
library 89.03% -4.45% 🍏
heatmaps 84.07% -0.19% 🍏
clustering 30.53% 🍏
Files
Module File Coverage
library PolyUtil.kt 97.87% 🍏
MapObjectManager.kt 92.12% -6.85% 🍏
CircleManager.kt 78.9% -18.35% 🍏
GroundOverlayManager.kt 78.9% -18.35% 🍏
PolylineManager.kt 78.9% -18.35% 🍏
PolygonManager.kt 78.9% -18.35% 🍏
MarkerManager.kt 78.16% -20.89% 🍏
heatmaps HeatmapTileProvider.kt 84.39% -0.27% 🍏
clustering ClusterManager.kt 68.5% 🍏

@dkhawk
dkhawk force-pushed the chore/lint-fixes branch 7 times, most recently from 3ce9d22 to 47e2e74 Compare August 26, 2026 20:19
@dkhawk
dkhawk requested review from LoyalAbbas and kikoso August 26, 2026 21:31
@kikoso

kikoso commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

It seems that this got lost during a merge or rebase on the big refactor branch.

The addAll/showAll/hideAll boilerplate (and the checkNotNull fix itself) is duplicated near-verbatim across all 5 manager classes rather than factored into the shared MapObjectManager.Collection base. Maybe we could unify this.

@dkhawk

dkhawk commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review, @kikoso!

The shared boilerplate across the 5 collection managers has now been unified into MapObjectManager.Collection:

  • showAll() & hideAll(): Factored into the base MapObjectManager.Collection using a polymorphic protected open fun setVisible(mapObject: O, visible: Boolean).
  • checkAndAdd(): Consolidated the null check and addition into a single helper in the base collection.
  • addAll(): Factored generic batch-addition helpers (addAll(opts, adder) and addAll(opts, defaultVisible, adder)) into the base collection.
  • Subclasses: CircleManager, PolygonManager, PolylineManager, GroundOverlayManager, and MarkerManager now inherit these methods directly with minimal delegate wrappers.
  • Tests: Expanded MapObjectManagerTest to directly verify showAll, hideAll, addAll, and checkAndAdd, with :library module unit test coverage increasing to 89.03%.

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.

3 participants