commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] [Commented] (CODEC-211) Create enum MessageDigestAlgorithm and deprecate class MessageDigestAlgorithms
Date Mon, 16 May 2016 14:35:13 GMT


Sebb commented on CODEC-211:

I now think the enum should be removed, as it does not appear to me to offer anything that
the original class did not.
Apart from looping through the values (which could easily be added to the original class).

The underlying JVM classes don't use enums - indeed they cannot, as the there is no complete
list of algorithms.
So the Codec classes have to accept Strings, but unless a parameter is constrained to use
an enum, then it is not constrained,
As far as validation is concerned, user code might as well use the constant strings from MessageDigestAlgorithms.
These are all guaranteed to work as the constants are chosen to ensure that they do work.

When using the new enum class, the code either has to inovoke a special method that only accepts
the enum, or it has to convert the enum to the algorithm name.
Both are more work for no gain in compile-time checking.

AFAICT there is no gain, only user pain from using an enum here.

> Create enum MessageDigestAlgorithm and deprecate class MessageDigestAlgorithms
> ------------------------------------------------------------------------------
>                 Key: CODEC-211
>                 URL:
>             Project: Commons Codec
>          Issue Type: New Feature
>    Affects Versions: 1.10
>         Environment: Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
> Maven home: E:\Java\apache-maven-3.3.9\bin\..
> Java version: 1.7.0_79, vendor: Oracle Corporation
> Java home: C:\Program Files\Java\jdk1.7.0_79\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>             Fix For: 1.11
> Create enum MessageDigestAlgorithm and deprecate class MessageDigestAlgorithms.

This message was sent by Atlassian JIRA

View raw message