Guest User

Untitled

a guest
Jul 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. public static <T> T nullSafe(Supplier<T> supplier, T fallback) {
  2. try {
  3. T result = supplier.get();
  4. return result != null
  5. ? result
  6. : fallback;
  7. } catch (NullPointerException npe) {
  8. return fallback;
  9. }
  10. }
Add Comment
Please, Sign In to add comment