Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-949

Modify the TEnum interface so it defines a method similar to findByValue

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 0.6
    • None

    Description

      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.

      Attachments

        1. THRIFT-949-1
          4 kB
          Mathias Herberts

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            herberts Mathias Herberts
            herberts Mathias Herberts
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment