Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4B6CC4E09 for ; Sat, 4 Jun 2011 19:32:31 +0000 (UTC) Received: (qmail 78188 invoked by uid 500); 4 Jun 2011 19:32:30 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 78106 invoked by uid 500); 4 Jun 2011 19:32:30 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 78098 invoked by uid 99); 4 Jun 2011 19:32:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Jun 2011 19:32:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Jun 2011 19:32:28 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 9647EF5834 for ; Sat, 4 Jun 2011 19:31:47 +0000 (UTC) Date: Sat, 4 Jun 2011 19:31:47 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Message-ID: <1450578507.68834.1307215907612.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <85488165.15148.1301239025737.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Closed] (NET-392) Use enum for IMAPCommand MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-392?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb closed NET-392. -------------------- > Use enum for IMAPCommand > ------------------------ > > Key: NET-392 > URL: https://issues.apache.org/jira/browse/NET-392 > Project: Commons Net > Issue Type: Sub-task > Reporter: Sebb > Fix For: 3.0 > > > As mentioned in the main issue, I think it would be better to use enums instead of int for the IMAP commands. > I agree that enums cannot be extended, but as far as I can tell, it won't be easy to extend the existing method either. > One can subclass IMAPCommand, but this won't be simple: > - how to prevent duplication of numbers if the parent class is later extended? > - how can the method IMAP.sendCommand(int command, String args) know where to pick up the new entries? > At present it references the static method IMAPCommand.getCommand(); it would probably be necessary to change this to use an instance of IMAPCommand and an instance method, which could then be overridden. > Seems to me that allowing extension via subclassing will make the code more complicated and fragile. > If new IMAP commands are added, the user can still pass in a String until such time as the code is updated. > Whereas if the code is changed to use enums, these can be used to provide additional validation - e.g. the enums could have an attribute that defines how many parameters are needed; this could then be checked. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira