Re: Optional.orElseChain ?

2015-04-28 Thread Paul Sandoz
Hi Remi, Chasing this up. I have not joined the dark-side just yet... but can you log an issue for this? Thanks, Paul. On Apr 20, 2015, at 4:27 PM, Remi Forax fo...@univ-mlv.fr wrote: On 04/20/2015 01:39 PM, Paul Sandoz wrote: Hi Remi, I was gonna propose the same trick you mentioned

Re: Optional.orElseChain ?

2015-04-20 Thread Paul Sandoz
Hi Remi, I was gonna propose the same trick you mentioned in your last email :-) Similar tricks are possible for other cases like an equivalent of the recently added ifPresentOrElse, but that was considered a little obtuse. On Apr 17, 2015, at 11:37 PM, Remi Forax fo...@univ-mlv.fr wrote:

Re: Optional.orElseChain ?

2015-04-20 Thread Remi Forax
On 04/20/2015 01:39 PM, Paul Sandoz wrote: Hi Remi, I was gonna propose the same trick you mentioned in your last email :-) yes, it's the same as optional.map(Stream::of).orElseGet(() - Stream.empty()) (I use orElseGet() because Stream.empty() is not a constant !). Similar tricks are

Re: Optional.orElseChain ?

2015-04-18 Thread Remi Forax
On 04/18/2015 01:58 AM, Andreas Lundblad wrote: On Fri, Apr 17, 2015 at 03:01:29PM -0700, Steven Schlansker wrote: On Apr 17, 2015, at 2:37 PM, Remi Forax fo...@univ-mlv.fr wrote: As you can see the code is not bad but the code of chain() could be simplified if there was a way on Optional to

Optional.orElseChain ?

2015-04-17 Thread Remi Forax
Hi guys, I was trying to write a code that uses Optional and I think one method is missing. Let suppose I want to load a type (like a class, an interface, etc) that can come either by reflection, or by using ASM. I will write an interface TypeProvider that is able to load a Type and i will

Re: Optional.orElseChain ?

2015-04-17 Thread Steven Schlansker
On Apr 17, 2015, at 2:37 PM, Remi Forax fo...@univ-mlv.fr wrote: As you can see the code is not bad but the code of chain() could be simplified if there was a way on Optional to call a Supplier of Optional if an Optional is empty. Currently, orElse() takes a value, orElseGet takes a lambda

Re: Optional.orElseChain ?

2015-04-17 Thread Andreas Lundblad
On Fri, Apr 17, 2015 at 03:01:29PM -0700, Steven Schlansker wrote: On Apr 17, 2015, at 2:37 PM, Remi Forax fo...@univ-mlv.fr wrote: As you can see the code is not bad but the code of chain() could be simplified if there was a way on Optional to call a Supplier of Optional if an