Libraryless. Click here for Pure Java version (2904L/17K).
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 <A> AutoCloseable tempSetField_conservativeUndo(ISetAndGet<A> 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 <A> AutoCloseable tempSetField_conservativeUndo(A value, ISetAndGet<A> gs) { ret tempSetField(gs, value); }
Began life as a copy of #1016243
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031595 |
Snippet name: | tempSetField_conservativeUndo |
Eternal ID of this version: | #1031595/1 |
Text MD5: | ac36ebeb86fdf7a97fc9dcea6b5634ab |
Transpilation MD5: | cee8da2634f5fa620289e30ce5324ed3 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-22 07:52:21 |
Source code size: | 591 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 145 / 215 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |