avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anders Sundelin <anders.sunde...@ericsson.com>
Subject Re: [jira] [Commented] (AVRO-1961) [JAVA] Generate getters that return an Optional
Date Fri, 25 Nov 2016 08:53:24 GMT
There are many arguments for/against Optionals on the web, but the 
consensus seem to be that Optionals are best used as method return 
types, not as method parameters.

Therefore, I think the setters should still use the plain objects, as 
there are anyway no practical way to enforce non-nullity of the arguments.






On 2016-11-25 00:47, Clueless Joe (JIRA) wrote:
>      [ https://issues.apache.org/jira/browse/AVRO-1961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15694432#comment-15694432
> Clueless Joe commented on AVRO-1961:
> ------------------------------------
> Thanks a lot for your answer. And don't forget I'm clueless, so it's all deeply open
to discussion :)
> I'll do a PR on your repo tomorrow night regarding the null part, so at least this part
will be solved.
> You're right to think of the transition We're using Avro at work and, to be honest, I
was rather thinking of some breaking changes in our dev branches. A smoother transition would
be great, but I don't see some currently. How would you  transition from the two getters (getFoo
and getOptionalFoo) to the one Optional<Foo> getFoo() later on?
> For the setters, at least having both, with setFoo(Foo fooOrNull) and setFoo(Optional<Foo>
foo), is doable code wise. Furthermore in the builder to have both seems handy. I would love
to have more feedbacks on the matter actually, to know everyone's feeling.
> Best
> cluelessjoe
>> [JAVA] Generate getters that return an Optional
>> -----------------------------------------------
>>                  Key: AVRO-1961
>>                  URL: https://issues.apache.org/jira/browse/AVRO-1961
>>              Project: Avro
>>           Issue Type: New Feature
>>             Reporter: Niels Basjes
>>             Assignee: Niels Basjes
>>             Priority: Minor
>> A colleague of mine indicated that having getters that return an Optional (java 8
thingy) would be very useful for him.
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)

View raw message