Skip to content

Complete Java to Kotlin migration for SDK #917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sumeruchat
Copy link
Collaborator

@sumeruchat sumeruchat commented Jun 24, 2025

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.

@joaodordio joaodordio requested a review from Copilot June 24, 2025 14:40
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request completes the migration of the Iterable SDK from Java to Kotlin by converting 26 files across the iterableapi module. Key changes include converting enums and data classes to idiomatic Kotlin, refactoring static utility classes into Kotlin objects, and updating complex builder patterns (notably in IterableConfig.kt).

Reviewed Changes

Copilot reviewed 48 out of 48 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
IOUtils.kt Java utility class migrated to a Kotlin object with similar functionality.
Future.kt Converted asynchronous task handling with callbacks into Kotlin while preserving behavior.
DeviceInfoUtils.kt Rewritten Kotlin utility with Android API calls and JSON handling.
MatchFpResponse.kt Data conversion with a companion object for JSON factory methods.
DeviceInfo.kt Complex builder pattern and nested class converted to Kotlin style.
IterableUrlHandler.kt Java interface translated to Kotlin interface.
IterableConfig.kt Critical configuration class reimplemented using a Kotlin builder pattern.
(and additional files) Other Java files such as enums, handlers, and utility classes have been fully migrated to Kotlin.

private IterableAPIMobileFrameworkInfo mobileFrameworkInfo;

public Builder() {}
val mobileFrameworkInfo: IterableAPIMobileFrameworkInfo? = builder.mobileFrameworkInfo
Copy link
Preview

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider refactoring the Builder implementation to use Kotlin’s apply scope function or a DSL approach so that the builder pattern is more concise and idiomatic.

Copilot uses AI. Check for mistakes.

callbacks = ArrayList(successCallbacks)
}
for (callback in callbacks) {
callback?.onSuccess(result)
Copy link
Preview

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Since callbacks are stored in a non-nullable list, consider removing the safe call operator to simplify the code and clearly indicate that callbacks should never be null.

Suggested change
callback?.onSuccess(result)
callback.onSuccess(result)

Copilot uses AI. Check for mistakes.

return try {
!(iterableTaskStorage.getNumberOfTasks() >= IterableConstants.OFFLINE_TASKS_LIMIT)
} catch (e: IllegalStateException) {
IterableLogger.e(TAG, e.localizedMessage)
Copy link
Preview

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider logging the full exception (or its stack trace) rather than only the localized message to aid in debugging, provided that no sensitive information is exposed.

Suggested change
IterableLogger.e(TAG, e.localizedMessage)
IterableLogger.e(TAG, "Exception occurred", e)

Copilot uses AI. Check for mistakes.

@Ayyanchira
Copy link
Member

Is it this tested against any tester app?

@sumeruchat
Copy link
Collaborator Author

No testing has been done just one pass by background agent. But if you like the direction I can finalize this PR? @Ayyanchira

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