groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-6744) Have the elvis operator (?:) support the Optional type in Java 8
Date Thu, 08 Jun 2017 23:53:18 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-6744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King updated GROOVY-6744:
------------------------------
    Labels: breaking  (was: )

> Have the elvis operator (?:) support the Optional type in Java 8
> ----------------------------------------------------------------
>
>                 Key: GROOVY-6744
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6744
>             Project: Groovy
>          Issue Type: New Feature
>          Components: Compiler
>            Reporter: Aadi Deshpande
>            Assignee: John Wagenleitner
>              Labels: breaking
>             Fix For: 2.5.0-beta-1
>
>
> With Java 8 and the rising popularity of Optional type in lieu of null management, it
would be great if  Groovy's elvis could handle Optional in the same way.
> {code:java}
> Optional<String> string1 = Optional.of("foo")
> Optional<String> string2 = Optional.empty()
> assert "foo" == ( string1 ?: "bar" )
> assert "bar" == ( string2 ?: "bar" )
> {code}
> Conversely, another option is to make elvis overloadable. ( something like {{orElse()}}
).
> That way, other Option/al types ( i.e. from Guava or FJ ) can have extension methods
to support their use as well.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message