### Question:
LangUtil { public static <T> void safeConsume(T obj, Consumer<T> action) { if (obj != null) action.accept(obj); }  static R safeOrElse(T obj, Function<T,R> getter, R def); static R safe(T obj, Function<T,R> getter); static R2 safeOrElse(T obj, Function<T,R1> getter1, Function<R1,R2> getter2, R2 def); static R2 safe(T obj, Function<T,R1> getter1, Function<R1,R2> getter2); static R3 safeOrElse(T obj, Function<T,R1> getter1, Function<R1,R2> getter2, Function<R2,R3> getter3, R3 def); static R3 safe(T obj, Function<T,R1> getter1, Function<R1,R2> getter2, Function<R2,R3> getter3); static R4 safeOrElse(T obj, Function<T,R1> getter1, Function<R1,R2> getter2, Function<R2,R3> getter3, Function<R3,R4> getter4, R4 def); static R4 safe(T obj, Function<T,R1> getter1, Function<R1,R2> getter2, Function<R2,R3> getter3, Function<R3,R4> getter4); static R5 safeOrElse(T obj, Function<T,R1> getter1, Function<R1,R2> getter2, Function<R2,R3> getter3, Function<R3,R4> getter4, Function<R4,R5> getter5, R5 def); static R5 safe(T obj, Function<T,R1> getter1, Function<R1,R2> getter2, Function<R2,R3> getter3, Function<R3,R4> getter4, Function<R4,R5> getter5); static void safeConsume(T obj, Consumer<T> action); static void doIf(boolean condition, Runnable action); static void doIfElse(boolean condition, Runnable ifAction, Runnable elseAction); static T orElse(T value, T fullBack); static T orElse(T value, Supplier<T> fullBack);  }### Answer:
@Test public void testSafeConsume() { A a = new A(new B(null)); LangUtil.safeConsume(a, A::clearB); assertNull(a.b); a = null; LangUtil.safeConsume(a, A::clearB); }