Skip to content

Instantly share code, notes, and snippets.

@jpitchardu
Created May 23, 2018 16:23
Show Gist options
  • Save jpitchardu/6d734019c4731f9b267f23b73b308c96 to your computer and use it in GitHub Desktop.
Save jpitchardu/6d734019c4731f9b267f23b73b308c96 to your computer and use it in GitHub Desktop.
Java's Optional API Example
SomeClass object;
Optional.ofNullable(object)
.map(obj -> obj.prop1)
.map(obj -> obj.prop2)
.map(obj -> obj.prop3)
.orElse("SomeDefaultValue");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment