RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-07 Thread Stuart Marks
Hi all, Please review this changeset that introduces a new no-arg method orElseThrow() to Optional, as a preferred alternative to the get() method. Corresponding methods are also added to OptionalDouble, Int, and Long. The orElseThrow() method is functionally identical to get(). It has some

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-07 Thread Brian Burkhalter
On Dec 7, 2017, at 4:33 PM, Stuart Marks wrote: > Please review this changeset that introduces a new no-arg method > orElseThrow() to Optional, as a preferred alternative to the get() method. Looks OK to me. > Corresponding methods are also added to OptionalDouble, Int, and Long. > > The orEl

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-08 Thread Alan Bateman
On 08/12/2017 00:33, Stuart Marks wrote: Hi all, Please review this changeset that introduces a new no-arg method orElseThrow() to Optional, as a preferred alternative to the get() method. This looks good. The naming is consistent and I think better than the "getWhenPresent" proposed in the

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-08 Thread Remi Forax
- Mail original - > De: "Alan Bateman" > À: "Stuart Marks" , "core-libs-dev" > > Envoyé: Vendredi 8 Décembre 2017 10:10:15 > Objet: Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred > alternative to get() >

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-08 Thread Remi Forax
ve the method mapTo*/flatMapTo* and Optional[Primitive] the method boxed(). regards, Rémi - Mail original - > De: "Stuart Marks" > À: "core-libs-dev" > Envoyé: Vendredi 8 Décembre 2017 01:33:41 > Objet: RFR(s): 8140281 add no-arg Optional.orElseThrow() as prefe

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-08 Thread Stuart Marks
Please review this changeset that introduces a new no-arg method orElseThrow() to Optional, as a preferred alternative to the get() method. This looks good. The naming is consistent and I think better than the "getWhenPresent" proposed in the original thread. i agree with Alan. Having a na

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-08 Thread Stuart Marks
the method boxed(). regards, Rémi - Mail original - De: "Stuart Marks" À: "core-libs-dev" Envoyé: Vendredi 8 Décembre 2017 01:33:41 Objet: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get() Hi all, Please review this changese

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-09 Thread Stephen Colebourne
On 8 December 2017 at 00:33, Stuart Marks wrote: > Please review this changeset that introduces a new no-arg method > orElseThrow() to Optional, as a preferred alternative to the get() method. I am willing to accept this addition as it has an obvious parallel to the existing supplier method. My

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-10 Thread forax
- Mail original - > De: "Stuart Marks" > À: "Remi Forax" > Cc: "core-libs-dev" > Envoyé: Samedi 9 Décembre 2017 01:00:06 > Objet: Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred > alternative to get() > Please, l

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-10 Thread forax
- Mail original - > De: "Stuart Marks" > À: "Remi Forax" , "Alan Bateman" > Cc: "core-libs-dev" > Envoyé: Samedi 9 Décembre 2017 00:48:08 > Objet: Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred > al

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-11 Thread Stuart Marks
On 12/9/17 1:20 AM, Stephen Colebourne wrote: On 8 December 2017 at 00:33, Stuart Marks wrote: Please review this changeset that introduces a new no-arg method orElseThrow() to Optional, as a preferred alternative to the get() method. I am willing to accept this addition as it has an obvious

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-18 Thread Tagir Valeev
Hello! I think that both methods could co-exist with slightly different semantics (even though they implementation is identical): The get() method should be called when it's evident from the narrow context that Optional is present at the point and using functional alternatives (like ifPresent())

Re: RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

2017-12-20 Thread Stuart Marks
On 12/18/17 2:31 AM, Tagir Valeev wrote: I think that both methods could co-exist with slightly different semantics (even though they implementation is identical): ... Think of get() as an assertion-like method: if get() throws, then it's a bug in the code (most likely right in this method). ..