diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index eca03ea495..a6df6374cf 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -59,6 +59,7 @@ import java.security.spec.KeySpec; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import java.util.Objects; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -677,9 +678,9 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On folder.account = account.id; folder.id = db.folder().insertFolder(folder); - if (swipe_left != null && swipe_left.equals(id)) + if (Objects.equals(swipe_left, id)) account.swipe_left = folder.id; - if (swipe_right != null && swipe_right.equals(id)) + if (Objects.equals(swipe_right, id)) account.swipe_right = folder.id; if (jfolder.has("rules")) { diff --git a/app/src/main/java/eu/faircode/email/EntityAccount.java b/app/src/main/java/eu/faircode/email/EntityAccount.java index 0d836f69cd..2e3dc35bd6 100644 --- a/app/src/main/java/eu/faircode/email/EntityAccount.java +++ b/app/src/main/java/eu/faircode/email/EntityAccount.java @@ -29,6 +29,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.Serializable; +import java.util.Objects; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; @@ -197,22 +198,22 @@ public class EntityAccount implements Serializable { this.port.equals(other.port) && this.user.equals(other.user) && this.password.equals(other.password) && - (this.realm == null ? other.realm == null : this.realm.equals(other.realm)) && - (this.name == null ? other.name == null : this.name.equals(other.name)) && - (this.color == null ? other.color == null : this.color.equals(other.color)) && + Objects.equals(this.realm, other.realm) && + Objects.equals(this.name, other.name) && + Objects.equals(this.color, other.color) && this.synchronize.equals(other.synchronize) && this.primary.equals(other.primary) && this.notify.equals(other.notify) && this.browse.equals(other.browse) && - (this.swipe_left == null ? other.swipe_left == null : this.swipe_left.equals(other.swipe_left)) && - (this.swipe_right == null ? other.swipe_right == null : this.swipe_right.equals(other.swipe_right)) && + Objects.equals(this.swipe_left, other.swipe_left) && + Objects.equals(this.swipe_right, other.swipe_right) && this.poll_interval.equals(other.poll_interval) && - (this.prefix == null ? other.prefix == null : this.prefix.equals(other.prefix)) && - (this.created == null ? other.created == null : this.created.equals(other.created)) && - (this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) && - (this.state == null ? other.state == null : this.state.equals(other.state)) && - (this.error == null ? other.error == null : this.error.equals(other.error)) && - (this.last_connected == null ? other.last_connected == null : this.last_connected.equals(other.last_connected))); + Objects.equals(this.prefix, other.prefix) && + Objects.equals(this.created, other.created) && + Objects.equals(this.tbd, other.tbd) && + Objects.equals(this.state, other.state) && + Objects.equals(this.error, other.error) && + Objects.equals(this.last_connected, other.last_connected)); } else return false; } diff --git a/app/src/main/java/eu/faircode/email/EntityAttachment.java b/app/src/main/java/eu/faircode/email/EntityAttachment.java index c3bffb9ffa..687c57bab0 100644 --- a/app/src/main/java/eu/faircode/email/EntityAttachment.java +++ b/app/src/main/java/eu/faircode/email/EntityAttachment.java @@ -24,6 +24,7 @@ import android.content.Context; import java.io.File; import java.io.IOException; import java.util.List; +import java.util.Objects; import javax.mail.Part; @@ -107,13 +108,13 @@ public class EntityAttachment { EntityAttachment other = (EntityAttachment) obj; return (this.message.equals(other.message) && this.sequence.equals(other.sequence) && - (this.name == null ? other.name == null : this.name.equals(other.name)) && + Objects.equals(this.name, other.name) && this.type.equals(other.type) && - (this.disposition == null ? other.disposition == null : this.disposition.equals(other.disposition)) && - (this.cid == null ? other.cid == null : this.cid.equals(other.cid)) && - (this.encryption == null ? other.encryption == null : this.encryption.equals(other.encryption)) && - (this.size == null ? other.size == null : this.size.equals(other.size)) && - (this.progress == null ? other.progress == null : this.progress.equals(other.progress)) && + Objects.equals(this.disposition, other.disposition) && + Objects.equals(this.cid, other.cid) && + Objects.equals(this.encryption, other.encryption) && + Objects.equals(this.size, other.size) && + Objects.equals(this.progress, other.progress) && this.available.equals(other.available)); } else return false; diff --git a/app/src/main/java/eu/faircode/email/EntityFolder.java b/app/src/main/java/eu/faircode/email/EntityFolder.java index 4a67c90497..f87f363ff0 100644 --- a/app/src/main/java/eu/faircode/email/EntityFolder.java +++ b/app/src/main/java/eu/faircode/email/EntityFolder.java @@ -33,6 +33,7 @@ import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.Objects; import androidx.annotation.NonNull; import androidx.room.Entity; @@ -241,7 +242,7 @@ public class EntityFolder implements Serializable { if (obj instanceof EntityFolder) { EntityFolder other = (EntityFolder) obj; return (this.id.equals(other.id) && - (this.account == null ? other.account == null : this.account.equals(other.account)) && + Objects.equals(this.account, other.account) && this.name.equals(other.name) && this.type.equals(other.type) && this.level.equals(other.level) && @@ -250,16 +251,16 @@ public class EntityFolder implements Serializable { this.download.equals(other.download) && this.sync_days.equals(other.sync_days) && this.keep_days.equals(other.keep_days) && - (this.display == null ? other.display == null : this.display.equals(other.display)) && + Objects.equals(this.display, other.display) && this.hide == other.hide && this.unified == other.unified && this.notify == other.notify && Helper.equal(this.keywords, other.keywords) && - (this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) && - (this.state == null ? other.state == null : this.state.equals(other.state)) && - (this.sync_state == null ? other.sync_state == null : this.sync_state.equals(other.sync_state)) && - (this.error == null ? other.error == null : this.error.equals(other.error)) && - (this.last_sync == null ? other.last_sync == null : this.last_sync.equals(other.last_sync))); + Objects.equals(this.tbd, other.tbd) && + Objects.equals(this.state, other.state) && + Objects.equals(this.sync_state, other.sync_state) && + Objects.equals(this.error, other.error) && + Objects.equals(this.last_sync, other.last_sync)); } else return false; } diff --git a/app/src/main/java/eu/faircode/email/EntityIdentity.java b/app/src/main/java/eu/faircode/email/EntityIdentity.java index 2170e760d6..e70c8c2425 100644 --- a/app/src/main/java/eu/faircode/email/EntityIdentity.java +++ b/app/src/main/java/eu/faircode/email/EntityIdentity.java @@ -22,6 +22,8 @@ package eu.faircode.email; import org.json.JSONException; import org.json.JSONObject; +import java.util.Objects; + import androidx.annotation.NonNull; import androidx.room.Entity; import androidx.room.ForeignKey; @@ -188,9 +190,9 @@ public class EntityIdentity { return (this.name.equals(other.name) && this.email.equals(other.email) && this.account.equals(other.account) && - (this.display == null ? other.display == null : this.display.equals(other.display)) && - (this.color == null ? other.color == null : this.color.equals(other.color)) && - (this.signature == null ? other.signature == null : this.signature.equals(other.signature)) && + Objects.equals(this.display, other.display) && + Objects.equals(this.color, other.color) && + Objects.equals(this.signature, other.signature) && this.auth_type.equals(other.auth_type) && this.host.equals(other.host) && this.starttls.equals(other.starttls) && @@ -198,21 +200,21 @@ public class EntityIdentity { this.port.equals(other.port) && this.user.equals(other.user) && this.password.equals(other.password) && - (this.realm == null ? other.realm == null : this.realm.equals(other.realm)) && + Objects.equals(this.realm, other.realm) && this.use_ip == other.use_ip && this.synchronize.equals(other.synchronize) && this.primary.equals(other.primary) && - (this.replyto == null ? other.replyto == null : this.replyto.equals(other.replyto)) && - (this.bcc == null ? other.bcc == null : this.bcc.equals(other.bcc)) && + Objects.equals(this.replyto, other.replyto) && + Objects.equals(this.bcc, other.bcc) && this.plain_only.equals(other.plain_only) && this.encrypt.equals(other.encrypt) && this.delivery_receipt.equals(other.delivery_receipt) && this.read_receipt.equals(other.read_receipt) && this.store_sent.equals(other.store_sent) && - (this.tbd == null ? other.tbd == null : this.tbd.equals(other.tbd)) && - (this.state == null ? other.state == null : this.state.equals(other.state)) && - (this.error == null ? other.error == null : this.error.equals(other.error)) && - (this.last_connected == null ? other.last_connected == null : this.last_connected.equals(other.last_connected))); + Objects.equals(this.tbd, other.tbd) && + Objects.equals(this.state, other.state) && + Objects.equals(this.error, other.error) && + Objects.equals(this.last_connected, other.last_connected)); } else return false; } diff --git a/app/src/main/java/eu/faircode/email/EntityMessage.java b/app/src/main/java/eu/faircode/email/EntityMessage.java index d57777c54d..5bac7f9205 100644 --- a/app/src/main/java/eu/faircode/email/EntityMessage.java +++ b/app/src/main/java/eu/faircode/email/EntityMessage.java @@ -27,6 +27,7 @@ import android.content.Intent; import java.io.File; import java.io.Serializable; import java.util.Date; +import java.util.Objects; import java.util.Random; import javax.mail.Address; @@ -195,30 +196,30 @@ public class EntityMessage implements Serializable { //(this.identity == null ? other.identity == null : this.identity.equals(other.identity)) && //(this.replying == null ? other.replying == null : this.replying.equals(other.replying)) && //(this.forwarding == null ? other.forwarding == null : this.forwarding.equals(other.forwarding)) && - (this.uid == null ? other.uid == null : this.uid.equals(other.uid)) && - (this.msgid == null ? other.msgid == null : this.msgid.equals(other.msgid)) && // debug info + Objects.equals(this.uid, other.uid) && + Objects.equals(this.msgid, other.msgid) && // debug info //(this.references == null ? other.references == null : this.references.equals(other.references)) && //(this.deliveredto == null ? other.deliveredto == null : this.deliveredto.equals(other.deliveredto)) && //(this.inreplyto == null ? other.inreplyto == null : this.inreplyto.equals(other.inreplyto)) && - (this.thread == null ? other.thread == null : this.thread.equals(other.thread)) && + Objects.equals(this.thread, other.thread) && MessageHelper.equal(this.from, other.from) && MessageHelper.equal(this.to, other.to) && MessageHelper.equal(this.cc, other.cc) && MessageHelper.equal(this.bcc, other.bcc) && MessageHelper.equal(this.reply, other.reply) && - (this.headers == null ? other.headers == null : this.headers.equals(other.headers)) && - (this.raw == null ? other.raw == null : this.raw.equals(other.raw)) && - (this.subject == null ? other.subject == null : this.subject.equals(other.subject)) && - (this.size == null ? other.size == null : this.size.equals(other.size)) && + Objects.equals(this.headers, other.headers) && + Objects.equals(this.raw, other.raw) && + Objects.equals(this.subject, other.subject) && + Objects.equals(this.size, other.size) && this.content == other.content && - (this.preview == null ? other.preview == null : this.preview.equals(other.preview)) && + Objects.equals(this.preview, other.preview) && //(this.sent == null ? other.sent == null : this.sent.equals(other.sent)) && this.received.equals(other.received) && this.stored.equals(other.stored) && // updated after decryption //this.seen.equals(other.seen) && //this.answered.equals(other.answered) && //this.flagged.equals(other.flagged) && - (!BuildConfig.DEBUG || (this.flags == null ? other.flags == null : this.flags.equals(other.flags))) && + (!BuildConfig.DEBUG || Objects.equals(this.flags, other.flags)) && Helper.equal(this.keywords, other.keywords) && this.ui_seen.equals(other.ui_seen) && this.ui_answered.equals(other.ui_answered) && @@ -227,9 +228,9 @@ public class EntityMessage implements Serializable { this.ui_found.equals(other.ui_found) && this.ui_ignored.equals(other.ui_ignored) && this.ui_browsed.equals(other.ui_browsed) && - (this.ui_snoozed == null ? other.ui_snoozed == null : this.ui_snoozed.equals(other.ui_snoozed)) && - (this.warning == null ? other.warning == null : this.warning.equals(other.warning)) && - (this.error == null ? other.error == null : this.error.equals(other.error)) && + Objects.equals(this.ui_snoozed, other.ui_snoozed) && + Objects.equals(this.warning, other.warning) && + Objects.equals(this.error, other.error) && this.day == other.day); } return false; @@ -239,33 +240,33 @@ public class EntityMessage implements Serializable { public boolean equals(Object obj) { if (obj instanceof EntityMessage) { EntityMessage other = (EntityMessage) obj; - return ((this.account == null ? other.account == null : this.account.equals(other.account)) && + return (Objects.equals(this.account, other.account) && this.folder.equals(other.folder) && - (this.identity == null ? other.identity == null : this.identity.equals(other.identity)) && - (this.uid == null ? other.uid == null : this.uid.equals(other.uid)) && - (this.msgid == null ? other.msgid == null : this.msgid.equals(other.msgid)) && - (this.references == null ? other.references == null : this.references.equals(other.references)) && - (this.deliveredto == null ? other.deliveredto == null : this.deliveredto.equals(other.deliveredto)) && - (this.inreplyto == null ? other.inreplyto == null : this.inreplyto.equals(other.inreplyto)) && - (this.thread == null ? other.thread == null : this.thread.equals(other.thread)) && + Objects.equals(this.identity, other.identity) && + Objects.equals(this.uid, other.uid) && + Objects.equals(this.msgid, other.msgid) && + Objects.equals(this.references, other.references) && + Objects.equals(this.deliveredto, other.deliveredto) && + Objects.equals(this.inreplyto, other.inreplyto) && + Objects.equals(this.thread, other.thread) && MessageHelper.equal(this.from, other.from) && MessageHelper.equal(this.to, other.to) && MessageHelper.equal(this.cc, other.cc) && MessageHelper.equal(this.bcc, other.bcc) && MessageHelper.equal(this.reply, other.reply) && - (this.headers == null ? other.headers == null : this.headers.equals(other.headers)) && - (this.raw == null ? other.raw == null : this.raw.equals(other.raw)) && - (this.subject == null ? other.subject == null : this.subject.equals(other.subject)) && - (this.size == null ? other.size == null : this.size.equals(other.size)) && + Objects.equals(this.headers, other.headers) && + Objects.equals(this.raw, other.raw) && + Objects.equals(this.subject, other.subject) && + Objects.equals(this.size, other.size) && this.content == other.content && - (this.preview == null ? other.preview == null : this.preview.equals(other.preview)) && - (this.sent == null ? other.sent == null : this.sent.equals(other.sent)) && + Objects.equals(this.preview, other.preview) && + Objects.equals(this.sent, other.sent) && this.received.equals(other.received) && this.stored.equals(other.stored) && this.seen.equals(other.seen) && this.answered.equals(other.answered) && this.flagged.equals(other.flagged) && - (this.flags == null ? other.flags == null : this.flags.equals(other.flags)) && + Objects.equals(this.flags, other.flags) && Helper.equal(this.keywords, other.keywords) && this.ui_seen.equals(other.ui_seen) && this.ui_answered.equals(other.ui_answered) && @@ -274,9 +275,9 @@ public class EntityMessage implements Serializable { this.ui_found.equals(other.ui_found) && this.ui_ignored.equals(other.ui_ignored) && this.ui_browsed.equals(other.ui_browsed) && - (this.ui_snoozed == null ? other.ui_snoozed == null : this.ui_snoozed.equals(other.ui_snoozed)) && - (this.warning == null ? other.warning == null : this.warning.equals(other.warning)) && - (this.error == null ? other.error == null : this.error.equals(other.error))); + Objects.equals(this.ui_snoozed, other.ui_snoozed) && + Objects.equals(this.warning, other.warning) && + Objects.equals(this.error, other.error)); } return false; } diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java index 7a138f88ce..1ab4d243e9 100644 --- a/app/src/main/java/eu/faircode/email/EntityOperation.java +++ b/app/src/main/java/eu/faircode/email/EntityOperation.java @@ -29,6 +29,7 @@ import org.json.JSONException; import java.io.IOException; import java.util.Calendar; import java.util.Date; +import java.util.Objects; import androidx.annotation.NonNull; import androidx.room.Entity; @@ -242,11 +243,11 @@ public class EntityOperation { if (obj instanceof EntityOperation) { EntityOperation other = (EntityOperation) obj; return (this.folder.equals(other.folder) && - (this.message == null ? other.message == null : this.message.equals(other.message)) && + Objects.equals(this.message, other.message) && this.name.equals(other.name) && this.args.equals(other.args) && this.created.equals(other.created) && - (this.error == null ? other.error == null : this.error.equals(other.error))); + Objects.equals(this.error, other.error)); } else return false; } diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 5c343077be..a3136a1361 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -70,6 +70,7 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.Properties; import javax.mail.AuthenticationFailedException; @@ -857,9 +858,9 @@ public class FragmentAccount extends FragmentBase { auth_type != account.auth_type || !host.equals(account.host) || Integer.parseInt(port) != account.port || !user.equals(account.user) || !password.equals(account.password) || - (realm == null ? accountRealm != null : !realm.equals(accountRealm)))); + !Objects.equals(realm, accountRealm))); boolean reload = (check || account == null || - (account.prefix == null ? prefix != null : !account.prefix.equals(prefix)) || + !Objects.equals(account.prefix, prefix) || account.synchronize != synchronize || account.ondemand != ondemand || !account.poll_interval.equals(Integer.parseInt(interval))); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index e97151b8d2..f28d741318 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -109,6 +109,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.Properties; import javax.mail.Address; @@ -1986,13 +1987,13 @@ public class FragmentCompose extends FragmentBase { available++; Long ident = (identity == null ? null : identity.id); - boolean dirty = ((draft.identity == null ? ident != null : !draft.identity.equals(ident)) || - (draft.extra == null ? extra != null : !draft.extra.equals(extra)) || + boolean dirty = (!Objects.equals(draft.identity, ident) || + !Objects.equals(draft.extra, extra) || !MessageHelper.equal(draft.from, afrom) || !MessageHelper.equal(draft.to, ato) || !MessageHelper.equal(draft.cc, acc) || !MessageHelper.equal(draft.bcc, abcc) || - (draft.subject == null ? subject != null : !draft.subject.equals(subject)) || + !Objects.equals(draft.subject, subject) || last_available != available || !body.equals(Helper.readText(EntityMessage.getFile(context, draft.id)))); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 0e06c79bc4..d8d7b6956d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -57,6 +57,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Properties; import javax.mail.AuthenticationFailedException; @@ -197,7 +198,7 @@ public class FragmentIdentity extends FragmentBase { tilPassword.setPasswordVisibilityToggleEnabled(position == 0); Integer tag = (Integer) adapterView.getTag(); - if (tag != null && tag.equals(position)) + if (Objects.equals(tag, position)) return; adapterView.setTag(position); @@ -334,7 +335,7 @@ public class FragmentIdentity extends FragmentBase { @Override public void onItemSelected(AdapterView adapterView, View view, int position, long id) { Integer tag = (Integer) adapterView.getTag(); - if (tag != null && tag.equals(position)) + if (Objects.equals(tag, position)) return; adapterView.setTag(position); @@ -584,7 +585,7 @@ public class FragmentIdentity extends FragmentBase { auth_type != identity.auth_type || !host.equals(identity.host) || Integer.parseInt(port) != identity.port || !user.equals(identity.user) || !password.equals(identity.password) || - (realm == null ? identityRealm != null : !realm.equals(identityRealm)) || + !Objects.equals(realm, identityRealm) || use_ip != identity.use_ip)); boolean reload = (identity == null || identity.synchronize != synchronize || check); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index f6e2e0f344..3e319f65b5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -50,6 +50,7 @@ import android.widget.TimePicker; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; +import java.util.Objects; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -254,7 +255,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O @Override public void onItemSelected(AdapterView adapterView, View view, int position, long id) { Integer prev = (Integer) adapterView.getTag(); - if (prev == null || !prev.equals(position)) { + if (!Objects.equals(prev, position)) { adapterView.setTag(position); int[] values = getResources().getIntArray(R.array.downloadValues); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index ae5ffcf434..75c1f5ea0d 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -86,6 +86,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ThreadFactory; import javax.mail.Address; @@ -972,7 +973,7 @@ public class Helper { public static boolean hasValidFingerprint(Context context) { String signed = getFingerprint(context); String expected = context.getString(R.string.fingerprint); - return (signed != null && signed.equals(expected)); + return Objects.equals(signed, expected); } static boolean isPro(Context context) { diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 5606a8c8af..0f1a544367 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -86,6 +86,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -2814,7 +2815,7 @@ public class ServiceSynchronize extends LifecycleService { Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " flagged=" + flagged); } - if (flags == null ? message.flags != null : !flags.equals(message.flags)) { + if (!Objects.equals(flags, message.flags)) { update = true; message.flags = flags; Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " flags=" + flags); diff --git a/app/src/main/java/eu/faircode/email/TupleFolderEx.java b/app/src/main/java/eu/faircode/email/TupleFolderEx.java index febd9e78fe..a201ea2988 100644 --- a/app/src/main/java/eu/faircode/email/TupleFolderEx.java +++ b/app/src/main/java/eu/faircode/email/TupleFolderEx.java @@ -19,6 +19,8 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import java.util.Objects; + public class TupleFolderEx extends EntityFolder { public String accountName; public Integer accountColor; @@ -32,9 +34,9 @@ public class TupleFolderEx extends EntityFolder { if (obj instanceof TupleFolderEx) { TupleFolderEx other = (TupleFolderEx) obj; return (super.equals(obj) && - (this.accountName == null ? other.accountName == null : accountName.equals(other.accountName)) && - (this.accountColor == null ? other.accountColor == null : this.accountColor.equals(other.accountColor)) && - (this.accountState == null ? other.accountState == null : accountState.equals(other.accountState)) && + Objects.equals(accountName, other.accountName) && + Objects.equals(this.accountColor, other.accountColor) && + Objects.equals(accountState, other.accountState) && this.messages == other.messages && this.content == other.content && this.unseen == other.unseen); diff --git a/app/src/main/java/eu/faircode/email/TupleIdentityEx.java b/app/src/main/java/eu/faircode/email/TupleIdentityEx.java index cec7c4bfbc..20f35a3a99 100644 --- a/app/src/main/java/eu/faircode/email/TupleIdentityEx.java +++ b/app/src/main/java/eu/faircode/email/TupleIdentityEx.java @@ -19,6 +19,8 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import java.util.Objects; + public class TupleIdentityEx extends EntityIdentity { public String accountName; @@ -27,7 +29,7 @@ public class TupleIdentityEx extends EntityIdentity { if (obj instanceof TupleIdentityEx) { TupleIdentityEx other = (TupleIdentityEx) obj; return (super.equals(obj) && - (this.accountName == null ? other.accountName == null : accountName.equals(other.accountName))); + Objects.equals(accountName, other.accountName)); } else return false; } diff --git a/app/src/main/java/eu/faircode/email/TupleMessageEx.java b/app/src/main/java/eu/faircode/email/TupleMessageEx.java index 0cc81f5ebe..1da6763c10 100644 --- a/app/src/main/java/eu/faircode/email/TupleMessageEx.java +++ b/app/src/main/java/eu/faircode/email/TupleMessageEx.java @@ -19,6 +19,8 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import java.util.Objects; + import androidx.room.Ignore; public class TupleMessageEx extends EntityMessage { @@ -45,15 +47,15 @@ public class TupleMessageEx extends EntityMessage { if (obj instanceof TupleMessageEx) { TupleMessageEx other = (TupleMessageEx) obj; return (super.uiEquals(obj) && - (this.accountName == null ? other.accountName == null : this.accountName.equals(other.accountName)) && - (this.accountColor == null ? other.accountColor == null : this.accountColor.equals(other.accountColor)) && + Objects.equals(this.accountName, other.accountName) && + Objects.equals(this.accountColor, other.accountColor) && //this.accountNotify == other.accountNotify && this.folderName.equals(other.folderName) && - (this.folderDisplay == null ? other.folderDisplay == null : this.folderDisplay.equals(other.folderDisplay)) && + Objects.equals(this.folderDisplay, other.folderDisplay) && this.folderType.equals(other.folderType) && - (this.identityName == null ? other.identityName == null : this.identityName.equals(other.identityName)) && - (this.identityEmail == null ? other.identityEmail == null : this.identityEmail.equals(other.identityEmail)) && - (this.identitySynchronize == null ? other.identitySynchronize == null : this.identitySynchronize.equals(other.identitySynchronize)) && + Objects.equals(this.identityName, other.identityName) && + Objects.equals(this.identityEmail, other.identityEmail) && + Objects.equals(this.identitySynchronize, other.identitySynchronize) && this.count == other.count && this.unseen == other.unseen && this.unflagged == other.unflagged && @@ -70,11 +72,11 @@ public class TupleMessageEx extends EntityMessage { if (obj instanceof TupleMessageEx) { TupleMessageEx other = (TupleMessageEx) obj; return (super.equals(obj) && - (this.accountName == null ? other.accountName == null : this.accountName.equals(other.accountName)) && - (this.accountColor == null ? other.accountColor == null : this.accountColor.equals(other.accountColor)) && + Objects.equals(this.accountName, other.accountName) && + Objects.equals(this.accountColor, other.accountColor) && this.accountNotify == other.accountNotify && this.folderName.equals(other.folderName) && - (this.folderDisplay == null ? other.folderDisplay == null : this.folderDisplay.equals(other.folderDisplay)) && + Objects.equals(this.folderDisplay, other.folderDisplay) && this.folderType.equals(other.folderType) && this.count == other.count && this.unseen == other.unseen && diff --git a/app/src/main/java/eu/faircode/email/TupleOperationEx.java b/app/src/main/java/eu/faircode/email/TupleOperationEx.java index 8999f4dc7b..e2c54c1392 100644 --- a/app/src/main/java/eu/faircode/email/TupleOperationEx.java +++ b/app/src/main/java/eu/faircode/email/TupleOperationEx.java @@ -19,6 +19,8 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import java.util.Objects; + public class TupleOperationEx extends EntityOperation { public String accountName; public String folderName; @@ -29,8 +31,8 @@ public class TupleOperationEx extends EntityOperation { if (obj instanceof TupleOperationEx) { TupleOperationEx other = (TupleOperationEx) obj; return (super.equals(obj) && - (this.accountName == null ? other.accountName == null : accountName.equals(other.accountName)) && - (this.folderName == null ? other.folderName == null : this.folderName.equals(other.folderName)) && + Objects.equals(accountName, other.accountName) && + Objects.equals(this.folderName, other.folderName) && this.synchronize == other.synchronize); } else return false; diff --git a/app/src/main/java/eu/faircode/email/TupleRuleEx.java b/app/src/main/java/eu/faircode/email/TupleRuleEx.java index 45dac45a9d..f3597fbca7 100644 --- a/app/src/main/java/eu/faircode/email/TupleRuleEx.java +++ b/app/src/main/java/eu/faircode/email/TupleRuleEx.java @@ -19,6 +19,8 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import java.util.Objects; + public class TupleRuleEx extends EntityRule { public long account; public String folderName; @@ -30,8 +32,8 @@ public class TupleRuleEx extends EntityRule { TupleRuleEx other = (TupleRuleEx) obj; return (super.equals(obj) && this.account == other.account && - (this.folderName == null ? other.folderName == null : this.folderName.equals(other.folderName)) && - (this.accountName == null ? other.accountName == null : this.accountName.equals(other.accountName))); + Objects.equals(this.folderName, other.folderName) && + Objects.equals(this.accountName, other.accountName)); } else return false; }