Libraryless. Click here for Pure Java version (7915L/44K).
static <A, B> AutoCloseable tempMapPutStrictlyOrFail(Map<A, B> map, A key, B value) { if (!(map != null && key != null && value != null)) null; B old = map.get(key); if (old == null) { map.put(key, value); ret -> map.remove(old); } if (eq(old, value)) null; fail("Can't overwrite key " + key + " (old value: " + old + ", new value: " + value); }
Began life as a copy of #1035360
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035362 |
Snippet name: | tempMapPutStrictlyOrFail - fail if value cannot be put strictly (i.e. not overwriting anything) |
Eternal ID of this version: | #1035362/1 |
Text MD5: | d27081f39312da4b6394bd1d0909ff7d |
Transpilation MD5: | 662fb4edd4710b61422d8a8265e1842b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-02 01:41:52 |
Source code size: | 374 bytes / 10 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 147 / 212 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |