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

Use a Java enum to represent field ids in generated structs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.2
    • Java - Compiler
    • None
    • Patch Available

    Description

      The way things work today, field IDs get constants in their structs, but all the methods take ints as parameters when they actually want a field id. This is not the best, since it can lead to accidentally putting in field ids that don't exist, and we have to do extra work to make sure things behave correctly.

      Instead, we should make the field IDs into a proper Java enum class, and make the methods take that class as the parameter type. That way, we'll get the compiler's help enforcing our use of only legal field IDs, plus easier association with name info, docstrings, etc. All in all, it should amount to a usability improvement.

      Attachments

        1. thrift-623-v3.patch
          44 kB
          Bryan Duxbury
        2. thrift-623-v2.patch
          44 kB
          Bryan Duxbury
        3. thrift-623.patch
          37 kB
          Bryan Duxbury

        Activity

          People

            bryanduxbury Bryan Duxbury
            bryanduxbury Bryan Duxbury
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: