Groovy Goodness: Use Optional In Conditional Context
In Groovy 2.5.0 we can use a Java 8 Optional
object in a conditional context.
When an Optional
object has a value the value is coerced to true
and when empty the value is false
.
In Groovy 2.5.0 we can use a Java 8 Optional
object in a conditional context.
When an Optional
object has a value the value is coerced to true
and when empty the value is false
.
We can introduce Groovy into our Java projects at grassroots level. Even if we aren't allowed to run the Groovy compiler we can use other ways to run Groovy code. As long as we can include the Groovy libraries as a compile dependency than we can already use Groovy from Java. In this post we see how we can use the power of XmlSlurper
to parse XML from our Java code.