Skip to content

Instantly share code, notes, and snippets.

@scottashipp
Created January 3, 2019 15:21
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 scottashipp/6a1ce1ac7ba9737a004e0d007844359e to your computer and use it in GitHub Desktop.
Save scottashipp/6a1ce1ac7ba9737a004e0d007844359e to your computer and use it in GitHub Desktop.
Use of Optional in place of a null-check
final Optional handle = (Optional)JAVA_9_PROCESSHANDLE_OF.invoke(null, pid);
if (handle.isPresent()) {
JAVA_9_PROCESSHANDLE_DESTROY.invoke(handle.get());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment