tipsy / j2html

Java to HTML generator. Enjoy typesafe HTML generation.
https://j2html.com/
Apache License 2.0
765 stars 136 forks source link

Overloaded method of iff for java8 Optional<>'s. (Includes test) #103

Closed niko-dunixi closed 6 years ago

niko-dunixi commented 6 years ago

Using an optional as a condition is really tricky. Even if the optional is not present, the right value of ifValue must be evaluated eagerly in order to be passed to the method. Passing a lambda function for ifFunction allows the value to be evaluated lazily. This avoids the need to manually map and "elseGet" a null value to preserve current functionality.

tipsy commented 6 years ago

@paul-nelson-baker cool!

tipsy commented 6 years ago

Looks good, merged.

niko-dunixi commented 6 years ago

Thanks! Hopefully more to come :)

tipsy commented 6 years ago

This has been released in 1.3.0 now.