You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/01/11 09:23:00 UTC

[jira] [Work logged] (LANG-1639) Find enum using a predicate

     [ https://issues.apache.org/jira/browse/LANG-1639?focusedWorklogId=534163&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-534163 ]

ASF GitHub Bot logged work on LANG-1639:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Jan/21 09:22
            Start Date: 11/Jan/21 09:22
    Worklog Time Spent: 10m 
      Work Description: bonii-xx opened a new pull request #696:
URL: https://github.com/apache/commons-lang/pull/696


    Adds a method to obtain a matching enum value based on a predicate. Quite useful when mapping values to enums.
   
   I used Optional as the return type since it allows the removal of a default value without removing any functionality, the caller has to handle the returned value if it's not found.


----------------------------------------------------------------
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:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 534163)
    Remaining Estimate: 0h
            Time Spent: 10m

> Find enum using a predicate
> ---------------------------
>
>                 Key: LANG-1639
>                 URL: https://issues.apache.org/jira/browse/LANG-1639
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.enums.*
>            Reporter: Bernhard Bonigl
>            Priority: Major
>             Fix For: 3.12
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> `EnumUtils` supports finding an enum based on its name. However in my experience it's often required to find an enum mapped by another value related to the enum. To use a very simple example: Mapping a string input to an enum, where the string does not match the enum name.
> I propose adding a `getEnumByPredicate` method, that returns the first found enum value matching a given predicate. Could also be expanded to return a list of all matching values.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)