iterable-android-sdk icon indicating copy to clipboard operation
iterable-android-sdk copied to clipboard

Complete Java to Kotlin migration for SDK

Open sumeruchat opened this issue 7 months ago • 2 comments

The session focused on migrating Java files to Kotlin, converting 26 files across the iterableapi/ module.

Key patterns applied include:

  • Java enums were converted to Kotlin enum class (e.g., AuthFailureReason.java, IterableDataRegion.java).
  • Data classes were refactored to use primary constructors and val properties, maintaining immutability (e.g., AuthFailure.java, CommerceItem.java).
  • Interfaces were translated to Kotlin interfaces (e.g., IterableAuthHandler.java, IterableCustomActionHandler.java).
  • Utility classes with static methods were converted to Kotlin object declarations (e.g., IOUtils.java, DeviceInfoUtils.java).
  • Classes with static members and nested classes now utilize companion object (e.g., DeviceInfo.java, IterableDatabaseManager.java).
  • Null safety was introduced using nullable types (%3F) and safe calls.
  • Complex builder patterns, notably in IterableConfig.java, were preserved, ensuring API compatibility.
  • Annotations like @RestrictTo and @Deprecated were retained.

The conversion of IterableConfig.java was a significant milestone, validating the approach for complex classes while maintaining API compatibility. Compilation checks confirmed no Kotlin-related errors, demonstrating successful migration of the selected files.

sumeruchat avatar Jun 24 '25 14:06 sumeruchat