[ https://issues.apache.org/jira/browse/THRIFT-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eirik Sletteberg updated THRIFT-1909: ------------------------------------- Attachment: add-option-type.patch This is the 2nd version of the patch (I just had to fix some typos in the first one) > Java: Add compiler flag to use the "option pattern" for optional fields > ----------------------------------------------------------------------- > > Key: THRIFT-1909 > URL: https://issues.apache.org/jira/browse/THRIFT-1909 > Project: Thrift > Issue Type: New Feature > Components: Java - Compiler, Java - Library > Reporter: Eirik Sletteberg > Attachments: add-option-type.patch > > > 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. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira