-
Notifications
You must be signed in to change notification settings - Fork 30
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
base: master
Are you sure you want to change the base?
Complete Java to Kotlin migration for SDK #917
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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) |
There was a problem hiding this comment.
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.
IterableLogger.e(TAG, e.localizedMessage) | |
IterableLogger.e(TAG, "Exception occurred", e) |
Copilot uses AI. Check for mistakes.
Is it this tested against any tester app? |
No testing has been done just one pass by background agent. But if you like the direction I can finalize this PR? @Ayyanchira |
The session focused on migrating Java files to Kotlin, converting 26 files across the
iterableapi/
module.Key patterns applied include:
enum class
(e.g.,AuthFailureReason.java
,IterableDataRegion.java
).val
properties, maintaining immutability (e.g.,AuthFailure.java
,CommerceItem.java
).IterableAuthHandler.java
,IterableCustomActionHandler.java
).object
declarations (e.g.,IOUtils.java
,DeviceInfoUtils.java
).companion object
(e.g.,DeviceInfo.java
,IterableDatabaseManager.java
).%3F
) and safe calls.IterableConfig.java
, were preserved, ensuring API compatibility.@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.