Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 532642d8 authored by Wolf Montwé's avatar Wolf Montwé
Browse files

Remove Preconditions

parent acb1d7fc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -86,8 +86,8 @@ import org.jetbrains.annotations.Nullable;
import timber.log.Timber;

import static com.fsck.k9.K9.MAX_SEND_ATTEMPTS;
import static com.fsck.k9.controller.Preconditions.requireNotNull;
import static com.fsck.k9.helper.ExceptionHelper.getRootCauseMessage;
import static com.fsck.k9.helper.Preconditions.checkNotNull;
import static com.fsck.k9.mail.Flag.X_REMOTE_COPY_STARTED;


@@ -863,7 +863,7 @@ public class MessagingController {
    @VisibleForTesting
    void processPendingMoveOrCopy(Account account, long srcFolderId, long destFolderId, List<String> uids,
                                  MoveOrCopyFlavor operation, Map<String, String> newUidMap) throws MessagingException {
        checkNotNull(newUidMap);
        requireNotNull(newUidMap);

        LocalStore localStore = localStoreProvider.getInstance(account);

+3 −3
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@ import com.fsck.k9.Account;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.MessagingException;

import static com.fsck.k9.controller.Preconditions.requireNotNull;
import static com.fsck.k9.controller.Preconditions.requireValidUids;
import static com.fsck.k9.helper.Preconditions.checkNotNull;


public class MessagingControllerCommands {
@@ -119,7 +119,7 @@ public class MessagingControllerCommands {


        public static PendingSetFlag create(long folderId, boolean newState, Flag flag, List<String> uids) {
            checkNotNull(flag);
            requireNotNull(flag);
            requireValidUids(uids);
            return new PendingSetFlag(folderId, newState, flag, uids);
        }
@@ -148,7 +148,7 @@ public class MessagingControllerCommands {


        public static PendingAppend create(long folderId, String uid) {
            checkNotNull(uid);
            requireNotNull(uid);
            return new PendingAppend(folderId, uid);
        }

+8 −4
Original line number Diff line number Diff line
@@ -4,22 +4,26 @@ package com.fsck.k9.controller

import com.fsck.k9.K9

fun <T : Any> requireNotNull(value: T?) {
    kotlin.requireNotNull(value)
}

fun requireValidUids(uidMap: Map<String?, String?>?) {
    requireNotNull(uidMap)
    kotlin.requireNotNull(uidMap)
    for ((sourceUid, destinationUid) in uidMap) {
        requireNotLocalUid(sourceUid)
        requireNotNull(destinationUid)
        kotlin.requireNotNull(destinationUid)
    }
}

fun requireValidUids(uids: List<String?>?) {
    requireNotNull(uids)
    kotlin.requireNotNull(uids)
    for (uid in uids) {
        requireNotLocalUid(uid)
    }
}

private fun requireNotLocalUid(uid: String?) {
    requireNotNull(uid)
    kotlin.requireNotNull(uid)
    require(!uid.startsWith(K9.LOCAL_UID_PREFIX)) { "Local UID found: $uid" }
}
+0 −12
Original line number Diff line number Diff line
package com.fsck.k9.helper;


public class Preconditions {
    public static <T> T checkNotNull(T reference) {
        if (reference == null) {
            throw new NullPointerException();
        }

        return reference;
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -2,8 +2,9 @@ package com.fsck.k9.storage.migrations;

import java.util.List;

import static com.fsck.k9.controller.Preconditions.requireNotNull;
import static com.fsck.k9.controller.Preconditions.requireValidUids;
import static com.fsck.k9.helper.Preconditions.checkNotNull;


class LegacyPendingDelete extends LegacyPendingCommand {
    public final String folder;
@@ -11,7 +12,7 @@ class LegacyPendingDelete extends LegacyPendingCommand {


    static LegacyPendingDelete create(String folder, List<String> uids) {
        checkNotNull(folder);
        requireNotNull(folder);
        requireValidUids(uids);
        return new LegacyPendingDelete(folder, uids);
    }