Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

9
LINES

< > BotCompany Repo | #1007227 // mapPut - put into map if key & value are not null

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (30L/1K).

static <A, B> void mapPut(Map<A, B> map, A key, B value) {
  if (map != null && key != null && value != null) map.put(key, value);
}

ifclass Pair
static <A, B> void mapPut(Map<A, B> map, Pair<A, B> p) {
  if (map != null && p != null) map.put(p.a, p.b);
}
endif

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1007227
Snippet name: mapPut - put into map if key & value are not null
Eternal ID of this version: #1007227/3
Text MD5: 5ddcc7447445f226b4eb71e91c850de6
Transpilation MD5: 24234ff0e601e07c85894d240c766e26
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-23 20:05:09
Source code size: 270 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 670 / 766
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1008061 - mapPutIfChange - put into map if key & value are not null & there is some change
#1008151 - mapPut2 - put into map if key & value are not null or delete key if value is null
#1008400 - putIfNotThere - mapPut if key not there
#1008781 - mapPutInRange - put into int range of keys
#1012146 - mapPutStrictly - return true if value can be put strictly (not overwriting anything)
#1014218 - putUnlessZero - put into map if int/double value != 0
#1015755 - mapPut_trueIfChanged
#1021598 - mapPutIfNemptyValue - put into map if key is not null & value is not empty
#1024976 - mapPut_noOverwrite - put into map if key & value are not null & key not there
#1027781 - mapPutVerbose - mapPut + print
#1031153 - removeAndPut - first remove key, then put it into map again [for MRUCache]
#1034293 - tempMapPut - put into map if key & value are not null