Libraryless. Click here for Pure Java version (7915L/44K).
1 | static <A, B> AutoCloseable tempMapPutStrictlyOrFail(Map<A, B> map, A key, B value) { |
2 | if (!(map != null && key != null && value != null)) null; |
3 | B old = map.get(key); |
4 | if (old == null) { |
5 | map.put(key, value); |
6 | ret -> map.remove(old); |
7 | } |
8 | if (eq(old, value)) null; |
9 | fail("Can't overwrite key " + key + " (old value: " + old + ", new value: " + value); |
10 | } |
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: | 148 / 214 |
Referenced in: | [show references] |