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

12
LINES

< > BotCompany Repo | #1022376 // replaceNullValuesWith - clone map, replace all nulö values with some object

JavaX fragment (include)

1  
static <A, B> Map<A, B> replaceNullValuesWith(Map<A, B> map, B value) {
2  
  if (map == null) null;
3  
  Map<A, B> m = similarEmptyMap(map);
4  
  for (A a, B b : map) {
5  
    m.put(a, or(b, value));
6  
  }
7  
  ret m;
8  
}
9  
10  
static <A, B> Map<A, B> replaceNullValuesWith(B value, Map<A, B> map) {
11  
  ret replaceNullValuesWith(map, value);
12  
}

Author comment

Began life as a copy of #1014256

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, lnbujpyubztb, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022376
Snippet name: replaceNullValuesWith - clone map, replace all nulö values with some object
Eternal ID of this version: #1022376/3
Text MD5: bad77487bc00509ab281719291ffdabe
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-16 12:08:55
Source code size: 329 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 334 / 353
Version history: 2 change(s)
Referenced in: [show references]