Last active
May 10, 2024 21:24
-
-
Save bogovicj/2c7f350eeb08ad9f55da31ac12afcb2c to your computer and use it in GitHub Desktop.
Use the map method to cause a side-effect if the optional is not-empty.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public T getValidateDefault(String parameter, Predicate<T> validator, T defaultValue) { | |
return getOptional(parameter).filter(validator) | |
.map(x -> { | |
allDefault = false; | |
return x; | |
}).orElse(defaultValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment