Skip to content

Instantly share code, notes, and snippets.

@zivce
Created April 17, 2021 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zivce/437ffbfe4597d7e5e971ffe027aa646d to your computer and use it in GitHub Desktop.
Save zivce/437ffbfe4597d7e5e971ffe027aa646d to your computer and use it in GitHub Desktop.
Optional<String> defaultStoreStatus = Optional.of("Store not found.");
public Optional<String> fetchStoreStatus(int storeId) {
Optional<String> foundStore = ... ; // fetch declared store status by id
if (foundStore.isPresent())
return foundStore;
else
return defaultStoreStatus;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment