ifValid

open fun <R> ifValid(consumer: (T) -> R): Optional<out R>

Applies consumer to the cached value and returns the result wrapped in Optional.Some, but only if the value is currently isValid; otherwise, returns Optional.None without forcing a (re)computation.