Affects Version/s: None
Fix Version/s: 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.