Skip to content

Commit

Permalink
refactor: Migrate Internal Constants class to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansi-mParticle committed Sep 26, 2024
1 parent a86cd3b commit 87d00c1
Show file tree
Hide file tree
Showing 10 changed files with 837 additions and 800 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public MParticleUser getCurrentUser() {
*/
@Nullable
public MParticleUser getUser(@NonNull Long mpid) {
if (!Constants.TEMPORARY_MPID.equals(mpid) && mConfigManager.mpidExists(mpid)) {
if (Constants.TEMPORARY_MPID != mpid && mConfigManager.mpidExists(mpid)) {
return MParticleUserImpl.getInstance(mContext, mpid, mUserDelegate);
} else {
return null;
Expand Down Expand Up @@ -252,7 +252,7 @@ public BaseIdentityTask modify(@NonNull final IdentityApiRequest updateRequest)
if (updateRequest.mpid == null) {
updateRequest.mpid = mConfigManager.getMpid();
}
if (Constants.TEMPORARY_MPID.equals(updateRequest.mpid)) {
if (Constants.TEMPORARY_MPID == updateRequest.mpid) {
String message = "modify() requires a non-zero MPID, please make sure a MParticleUser is present before making a modify request.";
if (devMode) {
throw new IllegalArgumentException(message);
Expand Down
67 changes: 0 additions & 67 deletions android-core/src/main/java/com/mparticle/internal/BatchId.java

This file was deleted.

637 changes: 0 additions & 637 deletions android-core/src/main/java/com/mparticle/internal/Constants.java

This file was deleted.

This file was deleted.

48 changes: 48 additions & 0 deletions android-core/src/main/kotlin/com/mparticle/internal/BatchId.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.mparticle.internal

import com.mparticle.internal.database.services.MessageService.ReadyMessage

class BatchId {
var mpid: Long
get() = field
var sessionId: String?
get() = field
var dataplanId: String?
get() = field
var dataplanVersion: Int?
get() = field

constructor(mpid: Long, sessionId: String?, dataplanId: String?, dataplanVersion: Int?) {
this.mpid = mpid
this.sessionId = sessionId
this.dataplanId = dataplanId
this.dataplanVersion = dataplanVersion
}

constructor(readyMessage: ReadyMessage) {
mpid = readyMessage.mpid
sessionId = readyMessage.sessionId
dataplanId = readyMessage.dataplanId
dataplanVersion = readyMessage.dataplanVersion
}

override fun equals(obj: Any?): Boolean {
if (obj !is BatchId) {
return false
}
for (i in 0 until fields().size) {
if (!MPUtility.isEqual(fields()[i], obj.fields()[i])) {
return false
}
}
return true
}

override fun hashCode(): Int {
return fields().contentHashCode()
}

private fun fields(): Array<Any?> {
return arrayOf(mpid, sessionId, dataplanId, dataplanVersion)
}
}
Loading

0 comments on commit 87d00c1

Please sign in to comment.