[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=335095&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-335095 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 18:26 Start Date: 28/Oct/19 18:26 Worklog Time Spent: 10m Work Description: garydgregory commented on pull request #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 335095) Time Spent: 1h 20m (was: 1h 10m) > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 1h 20m > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=334798&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334798 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 08:06 Start Date: 28/Oct/19 08:06 Worklog Time Spent: 10m Work Description: coveralls commented on issue #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475#issuecomment-546774618 [![Coverage Status](https://coveralls.io/builds/26584541/badge)](https://coveralls.io/builds/26584541) Coverage decreased (-0.006%) to 95.357% when pulling **ad4424480ddcd7ad7310677cbdf46926f081e370 on vlcheong:master** into **54afdb303535a62fe00e49e3ad5100ca9fc55d1e on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 334798) Time Spent: 1h 10m (was: 1h) > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 1h 10m > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=334797&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334797 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 08:04 Start Date: 28/Oct/19 08:04 Worklog Time Spent: 10m Work Description: vlcheong commented on pull request #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475#discussion_r339435243 ## File path: src/main/java/org/apache/commons/lang3/EnumUtils.java ## @@ -119,13 +119,29 @@ public EnumUtils() { * @return the enum, null if not found */ public static > E getEnum(final Class enumClass, final String enumName) { +return getEnum(enumClass, enumName, null); +} + +/** + * Gets the enum for the class, returning {@code defaultEnum} if not found. + * + * This method differs from {@link Enum#valueOf} in that it does not throw an exception + * for an invalid enum name. + * + * @param the type of the enumeration + * @param enumClass the class of the enum to query, not null + * @param enumNamethe enum name, null returns default enum + * @param defaultEnum the default enum + * @return the enum, default enum if not found Review comment: @Stzx, Thanks for your guidance. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 334797) Time Spent: 1h (was: 50m) > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 1h > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=334789&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334789 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 07:07 Start Date: 28/Oct/19 07:07 Worklog Time Spent: 10m Work Description: Stzx commented on pull request #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475#discussion_r339421728 ## File path: src/main/java/org/apache/commons/lang3/EnumUtils.java ## @@ -119,13 +119,29 @@ public EnumUtils() { * @return the enum, null if not found */ public static > E getEnum(final Class enumClass, final String enumName) { +return getEnum(enumClass, enumName, null); +} + +/** + * Gets the enum for the class, returning {@code defaultEnum} if not found. + * + * This method differs from {@link Enum#valueOf} in that it does not throw an exception + * for an invalid enum name. + * + * @param the type of the enumeration + * @param enumClass the class of the enum to query, not null + * @param enumNamethe enum name, null returns default enum + * @param defaultEnum the default enum + * @return the enum, default enum if not found Review comment: `3.10` :) This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 334789) Time Spent: 50m (was: 40m) > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 50m > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=334775&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334775 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 05:57 Start Date: 28/Oct/19 05:57 Worklog Time Spent: 10m Work Description: vlcheong commented on pull request #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475#discussion_r339410238 ## File path: src/main/java/org/apache/commons/lang3/EnumUtils.java ## @@ -119,13 +119,29 @@ public EnumUtils() { * @return the enum, null if not found */ public static > E getEnum(final Class enumClass, final String enumName) { +return getEnum(enumClass, enumName, null); +} + +/** + * Gets the enum for the class, returning {@code defaultEnum} if not found. + * + * This method differs from {@link Enum#valueOf} in that it does not throw an exception + * for an invalid enum name. + * + * @param the type of the enumeration + * @param enumClass the class of the enum to query, not null + * @param enumNamethe enum name, null returns default enum + * @param defaultEnum the default enum + * @return the enum, default enum if not found Review comment: @Stzx, may I know what version number should I put ? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 334775) Time Spent: 40m (was: 0.5h) > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 40m > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=334769&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334769 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 05:35 Start Date: 28/Oct/19 05:35 Worklog Time Spent: 10m Work Description: Stzx commented on pull request #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475#discussion_r339407030 ## File path: src/main/java/org/apache/commons/lang3/EnumUtils.java ## @@ -119,13 +119,29 @@ public EnumUtils() { * @return the enum, null if not found */ public static > E getEnum(final Class enumClass, final String enumName) { +return getEnum(enumClass, enumName, null); +} + +/** + * Gets the enum for the class, returning {@code defaultEnum} if not found. + * + * This method differs from {@link Enum#valueOf} in that it does not throw an exception + * for an invalid enum name. + * + * @param the type of the enumeration + * @param enumClass the class of the enum to query, not null + * @param enumNamethe enum name, null returns default enum + * @param defaultEnum the default enum + * @return the enum, default enum if not found Review comment: Provide a `@since` tag for the new method. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 334769) Time Spent: 0.5h (was: 20m) > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 0.5h > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=334728&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334728 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 03:11 Start Date: 28/Oct/19 03:11 Worklog Time Spent: 10m Work Description: coveralls commented on issue #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475#issuecomment-546774618 [![Coverage Status](https://coveralls.io/builds/26581425/badge)](https://coveralls.io/builds/26581425) Coverage increased (+0.0006%) to 95.364% when pulling **b8339538e9845496d4959ba640efbf988ea328d4 on vlcheong:master** into **54afdb303535a62fe00e49e3ad5100ca9fc55d1e on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 334728) Time Spent: 20m (was: 10m) > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 20m > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (LANG-1495) Add Overloading Methods To EnumUtils
[ https://issues.apache.org/jira/browse/LANG-1495?focusedWorklogId=334719&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334719 ] ASF GitHub Bot logged work on LANG-1495: Author: ASF GitHub Bot Created on: 28/Oct/19 02:58 Start Date: 28/Oct/19 02:58 Worklog Time Spent: 10m Work Description: vlcheong commented on pull request #475: LANG-1495 Update EnumUtils.java URL: https://github.com/apache/commons-lang/pull/475 Add Overloading Methods getEnum and getEnumIgnoreCase To EnumUtils This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 334719) Remaining Estimate: 0h Time Spent: 10m > Add Overloading Methods To EnumUtils > > > Key: LANG-1495 > URL: https://issues.apache.org/jira/browse/LANG-1495 > Project: Commons Lang > Issue Type: Improvement >Reporter: Cheong Voon Leong >Priority: Trivial > Time Spent: 10m > Remaining Estimate: 0h > > I would like to add 2 overloading methods to EnumUtils, getEnum and > getEnumIgnoreCase. > Instead of returning null, if not found. In my opinion I think allowing user > to set a default result is a better approach or return an Optional. > > {noformat} > public static > E getEnum(final Class enumClass, final > String enumName) { > return getEnum(enumClass, enumName, null); > } > public static > E getEnum(final Class enumClass, final > String enumName, E defaultEnum) { > if (enumName == null) { > return defaultEnum; > } > try { > return Enum.valueOf(enumClass, enumName); > } catch (final IllegalArgumentException ex) { > return defaultEnum; > } > } > {noformat} > > > {code:java} > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName) { > return getEnumIgnoreCase(enumClass, enumName, null); > } > public static > E getEnumIgnoreCase(final Class > enumClass, final String enumName, E defaultEnum) { > if (enumName == null || !enumClass.isEnum()) { > return defaultEnum; > } > for (final E each : enumClass.getEnumConstants()) { > if (each.name().equalsIgnoreCase(enumName)) { > return each; > } > } > return defaultEnum; > } > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)