Libraryless. Click here for Pure Java version (2887L/17K).
1 | static AutoCloseable tempSetField(O o, S field, O value) { |
2 | fO oldValue = get(o, field); |
3 | set(o, field, value); |
4 | ret () -> set(o, field, oldValue); |
5 | } |
6 | |
7 | static <A> AutoCloseable tempSetField(ISetAndGet<A> gs, A value) { |
8 | if (gs == null) null; // convenient null propagation as always in JavaX! |
9 | A oldValue = gs!; |
10 | gs.set(value); |
11 | ret () -> gs.set(oldValue); |
12 | } |
13 | |
14 | static <A> AutoCloseable tempSetField(A value, ISetAndGet<A> gs) { |
15 | ret tempSetField(gs, value); |
16 | } |
Began life as a copy of #1012933
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016243 |
Snippet name: | tempSetField |
Eternal ID of this version: | #1016243/4 |
Text MD5: | 1edc4a4d914a9d8a316bc247c21b371d |
Transpilation MD5: | 4622b6edd9324ef345a2002d1fea8360 |
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:50:05 |
Source code size: | 480 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 471 / 584 |
Version history: | 3 change(s) |
Referenced in: | [show references] |