Skip to content
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

refactor: Migrate Internal Constants class to kotlin #509

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading