package com.fsck.k9.account;


import com.fsck.k9.Account.DeletePolicy;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.ServerSettings.Type;

import java.util.HashMap;
import java.util.Map;


/**
 * Deals with logic surrounding account creation.
 * <p/>
 * TODO Move much of the code from com.fsck.k9.activity.setup.* into here
 */
public class AccountCreator {

    private static Map<Type, DeletePolicy> defaults = new HashMap<Type, DeletePolicy>();

    static {
        defaults.put(Type.IMAP, DeletePolicy.ON_DELETE);
        defaults.put(Type.POP3, DeletePolicy.NEVER);
        defaults.put(Type.WebDAV, DeletePolicy.ON_DELETE);
    }

    public static DeletePolicy calculateDefaultDeletePolicy(Type type) {
        return defaults.get(type);
    }

    public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) {
        switch (securityType) {
            case NONE:
            case STARTTLS_REQUIRED: {
                return storeType.defaultPort;
            }
            case SSL_TLS_REQUIRED: {
                return storeType.defaultTlsPort;
            }
        }

        throw new AssertionError("Unhandled ConnectionSecurity type encountered: " + securityType);
    }
}

@@ -159,57 +159,8 @@
 e;%0A%0A
-import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 %0A/**
@@ -336,31 +336,20 @@
    p
-rivate
+ublic
  static
- Map%3CType,
  Del
@@ -361,67 +361,72 @@
 licy
-%3E defaults = new HashMap%3CType, DeletePolicy%3E();%0A%0A    static
+ calculateDefaultDeletePolicy(Type type) %7B%0A        switch (type)
  %7B%0A 
@@ -436,31 +436,47 @@
     
+  
-defaults.put(Type.IMAP,
+  case IMAP: %7B%0A                return
  Del
@@ -490,25 +490,24 @@
 cy.ON_DELETE
-)
 ;%0A        de
@@ -508,31 +508,61 @@
     
-defaults.put(Type.POP3,
+    %7D%0A            case POP3: %7B%0A                return
  Del
@@ -576,17 +576,16 @@
 cy.NEVER
-)
 ;%0A      
@@ -590,33 +590,63 @@
     
+    
-defaults.put(Type.WebDAV,
+%7D%0A            case WebDAV: %7B%0A                return
  Del
@@ -668,119 +668,216 @@
 LETE
-)
 ;%0A    
-%7D%0A%0A    public static DeletePolicy calculateDefault
+        %7D%0A            case SMTP: %7B%0A                throw new IllegalStateException(%22
 Delete
-P
+ p
 olicy
-(Type type) %7B%0A        return defaults.get(
+ doesn't apply to SMTP%22);%0A            %7D%0A        %7D%0A%0A        throw new AssertionError(%22Unhandled case: %22 + 
 type

Use switch statement inside calculateDefaultDeletePolicy()