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

Java: Add compiler flag to use the "option pattern" for optional fields

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.9.3
    • None
    • Patch Available

    Description

      This is a follow-up of the brainstorming issue about better null safety in Java.

      The patch adds:
      1) A new abstract Option<T> class, with two subclasses: Some<T> and None<T>.
      2) An optional compiler flag for the java compiler. When set, it wraps methods for optional fields in Option types.

      An example of usage is found here: https://github.com/eirslett/thrift-optional-example

      • No java dependencies are introduced.
      • The patch is entirely backwards-compatible; if the compiler flag is not present, it will generate the same code as thrift usually does.
      • The implementation is compatible with thrift servers/clients where the compiler flag is not used.

      Attachments

        1. add-option-type.patch
          15 kB
          Eirik Sletteberg
        2. thrift-0.9.3-option_type.patch
          15 kB
          Wouter Lammers

        Issue Links

          Activity

            People

              roger Roger Meier
              eirslett Eirik Sletteberg
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: