You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/09/12 14:36:14 UTC

(commons-net) 02/04: Convert cascading if-else to switch

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit 15e3f6ef39157a4cd1bd04630f07c1998d860465
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 10:32:44 2024 -0400

    Convert cascading if-else to switch
---
 src/main/java/org/apache/commons/net/imap/IMAPReply.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/imap/IMAPReply.java b/src/main/java/org/apache/commons/net/imap/IMAPReply.java
index 59f954f7..ea8706d8 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAPReply.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAPReply.java
@@ -111,14 +111,15 @@ public final class IMAPReply {
         final Matcher m = pattern.matcher(line);
         if (m.matches()) { // TODO would lookingAt() be more efficient? If so, then drop trailing .* from patterns
             final String code = m.group(1);
-            if (code.equals(IMAP_OK)) {
+            switch (code) {
+            case IMAP_OK:
                 return OK;
-            }
-            if (code.equals(IMAP_BAD)) {
+            case IMAP_BAD:
                 return BAD;
-            }
-            if (code.equals(IMAP_NO)) {
+            case IMAP_NO:
                 return NO;
+            default:
+                break;
             }
         }
         throw new MalformedServerReplyException("Received unexpected IMAP protocol response from server: '" + line + "'.");