mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 09:52:16 -05:00
Use switch statement inside calculateDefaultDeletePolicy()
With this - at least in theory - the JIT compiler can produce better code than is possible with the static HashMap.
This commit is contained in:
parent
f733cc38ba
commit
5f14e3b4e1
@ -5,9 +5,6 @@ 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.
|
||||
@ -16,16 +13,23 @@ import java.util.Map;
|
||||
*/
|
||||
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);
|
||||
switch (type) {
|
||||
case IMAP: {
|
||||
return DeletePolicy.ON_DELETE;
|
||||
}
|
||||
case POP3: {
|
||||
return DeletePolicy.NEVER;
|
||||
}
|
||||
case WebDAV: {
|
||||
return DeletePolicy.ON_DELETE;
|
||||
}
|
||||
case SMTP: {
|
||||
throw new IllegalStateException("Delete policy doesn't apply to SMTP");
|
||||
}
|
||||
}
|
||||
|
||||
throw new AssertionError("Unhandled case: " + type);
|
||||
}
|
||||
|
||||
public static int getDefaultPort(ConnectionSecurity securityType, Type storeType) {
|
||||
|
Loading…
Reference in New Issue
Block a user