static AutoCloseable tempSetField_conservativeUndo(O o, S field, O value) { fO oldValue = get(o, field); set(o, field, value); ret () -> { if (eq(get(o, field), value)) set(o, field, oldValue); }; } static AutoCloseable tempSetField_conservativeUndo(ISetAndGet gs, A value) { if (gs == null) null; // convenient null propagation as always in JavaX! A oldValue = gs!; gs.set(value); ret () -> { if (eq(gs!, value)) gs.set(oldValue); }; } static AutoCloseable tempSetField_conservativeUndo(A value, ISetAndGet gs) { ret tempSetField(gs, value); }