You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Mathias Herberts (JIRA)" <ji...@apache.org> on 2010/10/26 22:47:25 UTC

[jira] Updated: (THRIFT-949) Modify the TEnum interface so it defines a method similar to findByValue

     [ https://issues.apache.org/jira/browse/THRIFT-949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mathias Herberts updated THRIFT-949:
------------------------------------

    Attachment: THRIFT-949-1

Adds TEnumHelper.java and associated tests.

> Modify the TEnum interface so it defines a method similar to findByValue
> ------------------------------------------------------------------------
>
>                 Key: THRIFT-949
>                 URL: https://issues.apache.org/jira/browse/THRIFT-949
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Compiler, Java - Library
>            Reporter: Mathias Herberts
>            Priority: Trivial
>         Attachments: THRIFT-949-1
>
>
> In some cases, Thrift instances are converted into more simple types. This is made easy by the existence of the meta data map.
> TEnum fields are usually converted to 'int' using getValue.
> When converting back to Thrift, those 'int' need to be converted back to TEnum.
> The generated TEnum classes have a static method findByValue, but as it is static it is not defined in the TEnum interface and therefore can only be accessed using reflection if the enum type is not know before runtime.
> By adding a simple 'public TEnum getByValue(int value)' method in the TEnum interface, we could get rid of the reflection part. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.