Skip to content

Instantly share code, notes, and snippets.

@eckelon
Last active March 9, 2017 16:13
Show Gist options
  • Save eckelon/e01998b34b73b9a9f03758f6aaa2faa8 to your computer and use it in GitHub Desktop.
Save eckelon/e01998b34b73b9a9f03758f6aaa2faa8 to your computer and use it in GitHub Desktop.
silly way for avoiding the use of massive ternary operators in Java
public static <T> T coalesce(T object) {
return object == null ? null : object;
}
public static <T> T coalesce(T find, T replace) {
return find == null ? replace : find;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment