Convert 'CommandExpunge' to Kotlin
-package com.fsck.k9.backend.imap;
+package com.fsck.k9.backend.imap
+import com.fsck.k9.mail.store.imap.ImapFolder
+import com.fsck.k9.mail.store.imap.ImapStore
+import timber.log.Timber
-import java.util.List;
+internal class CommandExpunge(private val imapStore: ImapStore) {
-import com.fsck.k9.mail.MessagingException;
-import com.fsck.k9.mail.store.imap.ImapFolder;
-import com.fsck.k9.mail.store.imap.ImapStore;
-import org.jetbrains.annotations.NotNull;
-import timber.log.Timber;
+ fun expunge(folderServerId: String) {
+ Timber.d("processPendingExpunge: folder = %s", folderServerId)
+ val remoteFolder = imapStore.getFolder(folderServerId)
+ try {
+ if (!remoteFolder.exists()) return
-class CommandExpunge {
- private final ImapStore imapStore;
-
-
- CommandExpunge(ImapStore imapStore) {
- this.imapStore = imapStore;
- }
-
- void expunge(@NotNull String folderServerId) throws MessagingException {
- Timber.d("processPendingExpunge: folder = %s", folderServerId);
+ remoteFolder.open(ImapFolder.OPEN_MODE_RW)
+ if (remoteFolder.mode != ImapFolder.OPEN_MODE_RW) return
- ImapFolder remoteFolder = imapStore.getFolder(folderServerId);
- try {
- if (!remoteFolder.exists()) {
- return;
- }
- remoteFolder.open(ImapFolder.OPEN_MODE_RW);
- if (remoteFolder.getMode() != ImapFolder.OPEN_MODE_RW) {
- return;
- }
- remoteFolder.expunge();
+ remoteFolder.expunge()
- Timber.d("processPendingExpunge: complete for folder = %s", folderServerId);
+ Timber.d("processPendingExpunge: complete for folder = %s", folderServerId)
} finally {
- remoteFolder.close();
+ remoteFolder.close()
}
}
- void expungeMessages(@NotNull String folderServerId, @NotNull List<String> messageServerIds)
- throws MessagingException {
- ImapFolder remoteFolder = imapStore.getFolder(folderServerId);
+ fun expungeMessages(folderServerId: String, messageServerIds: List<String>) {
+ val remoteFolder = imapStore.getFolder(folderServerId)
try {
- if (!remoteFolder.exists()) {
- return;
- }
- remoteFolder.open(ImapFolder.OPEN_MODE_RW);
- if (remoteFolder.getMode() != ImapFolder.OPEN_MODE_RW) {
- return;
- }
- remoteFolder.expungeUids(messageServerIds);
+ if (!remoteFolder.exists()) return
+
+ remoteFolder.open(ImapFolder.OPEN_MODE_RW)
+ if (remoteFolder.mode != ImapFolder.OPEN_MODE_RW) return
+
+ remoteFolder.expungeUids(messageServerIds)
} finally {
- remoteFolder.close();
+ remoteFolder.close()
}
}
}
