Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-13802 Flink code style guide
  3. FLINK-13812

Code style for the usage of Java Optional

    XMLWordPrintableJSON

    Details

      Description

      • Use @Nullable annotation where you do not use Optional for the nullable values
      • If you can prove that Optional usage would lead to a performance degradation in critical code then fallback to @Nullable
      • Always use Optional to return nullable values in the API/public methods except the case of a proven performance concern
      • Do not use Optional as a function argument, instead either overload the method or use the Builder pattern for the set of function arguments
        • Note: an Optional argument can be allowed in a private helper method if you believe that it simplifies the code (example])
      • Do not use Optional for class fields

        Attachments

          Activity

            People

            • Assignee:
              azagrebin Andrey Zagrebin
              Reporter:
              azagrebin Andrey Zagrebin
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m