Skip to content

AVRO-2639: add option to write Optional only when fields are nullable#726

Closed
ecopoesis wants to merge 1 commit intoapache:masterfrom
ecopoesis:feature/null-only-null
Closed

AVRO-2639: add option to write Optional only when fields are nullable#726
ecopoesis wants to merge 1 commit intoapache:masterfrom
ecopoesis:feature/null-only-null

Conversation

@ecopoesis
Copy link

@ecopoesis ecopoesis commented Nov 26, 2019

Make sure you have checked all steps below.

Jira

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

  • testPojoWithOptionalOnlyWhenNullableCreatedTurnedOn

  • testPojoWithOptionalOnlyWhenNullableCreatedTurnedOnAndGettersReturnOptionalTurnedOff

Commits

  • My commits all reference Jira issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain Javadoc that explain what it does

Adds a new option to SpecificCompiler: gettersReturnOptionalOnlyForNullable.
When enabled, and when gettersReturnOptional is also enabled, getters
will only return Optional when the underlying field in nullable.

This also improves the documentation for gettersReturnOptional and
createOptionalGetters, adding examples to both.
@probot-autolabeler probot-autolabeler bot added the Java Pull Requests for Java binding label Nov 26, 2019
@kan-izh
Copy link
Contributor

kan-izh commented Jan 31, 2020

Nice! While you are here, I think it is a good idea to tweak it further: Use OptionalInt/OptionalLong/OptionalDouble for corresponding primitive types.

@Bluexin
Copy link

Bluexin commented Apr 27, 2020

This looks like it implements the same functionality as #817, but that implementation's velocity template seemed a bit cleaner at first glance.
Regardless, is there something blocking this or the other PR? I don't mind helping out.

@daicode-jan
Copy link

Would be nice to have an update on this important feature

@Fokko
Copy link
Contributor

Fokko commented May 3, 2020

Thanks for the PR, I like this one. Would be much nicer if we could use the primitive types, as @kan-izh suggests.

@dkulp dkulp closed this in 734ea36 May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants