Instead of wrapping it in an optional you can do Objects.requireNonNullElse(value, defaultValue)
Objects.requireNonNullElse(value, defaultValue)
In java 9 there is Objects.requireNonNullElse(obj, defaultValue)
Objects.requireNonNullElse(obj, defaultValue)
Instead of wrapping it in an optional you can do
Objects.requireNonNullElse(value, defaultValue)