Created
October 27, 2020 23:33
-
-
Save MazizEsa/72d32ee19c59b87f03fedd21f65d6d0c to your computer and use it in GitHub Desktop.
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 void exampleMinimizingIfElse() { | |
final List<String> someExampleArray = new ArrayList<>(); | |
Optional.ofNullable(someExampleArray).orElse(Collections.emptyList()).forEach(this::doSomethingWithIt); | |
ObjectUtils.defaultIfNull(someExampleArray, Collections.<String>emptyList()).forEach(this::doSomethingWithIt); | |
returnEmptyArrayIfNecessary(someExampleArray).forEach(this::doSomethingWithIt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment