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

41
LINES

< > BotCompany Repo | #1019625 // mapNonNulls - map, then nonNulls

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

Libraryless. Click here for Pure Java version (2165L/14K).

1  
static L mapNonNulls(Iterable l, O f) { ret mapNonNulls(f, l); }
2  
3  
static L lambdaMapLike mapNonNulls(O f, Iterable l) {
4  
  new L x;
5  
  if (l != null) for (O o : l)
6  
    addIfNotNull(x, callF(f, o));
7  
  ret x;
8  
}
9  
10  
static L mapNonNulls(O f, O[] l) {
11  
  new L x;
12  
  if (l != null) for (O o : l)
13  
    addIfNotNull(x, callF(f, o));
14  
  ret x;
15  
}
16  
17  
ifclass F1
18  
  static <A, B> L<B> mapNonNulls(Iterable<A> l, F1<A, B> f) { ret mapNonNulls(f, l); }
19  
20  
  static <A, B> L<B> mapNonNulls(F1<A, B> f, Iterable<A> l) {
21  
    new L x;
22  
    if (l != null) for (O o : l)
23  
      addIfNotNull(x, callF(f, o));
24  
    ret x;
25  
  }
26  
endif
27  
28  
static <A, B> L<B> mapNonNulls(A[] l, IF1<A, B> f) {
29  
  ret mapNonNulls(f, l);
30  
}
31  
32  
static <A, B> L<B> mapNonNulls(Iterable<A> l, IF1<A, B> f) {
33  
  L x = emptyList(l);
34  
  if (l != null) for (A o : l)
35  
    addIfNotNull(x, f.get(o));
36  
  ret x;
37  
}
38  
39  
static <A, B> L<B> mapNonNulls(IF1<A, B> f, Iterable<A> l) {
40  
  ret mapNonNulls(l, f);
41  
}

Author comment

Began life as a copy of #1003239

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019625
Snippet name: mapNonNulls - map, then nonNulls
Eternal ID of this version: #1019625/8
Text MD5: 7169ae44d27062a49a3797406e8ebe44
Transpilation MD5: 432c4c04399eb8bc2f22823321be666f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-01 13:09:31
Source code size: 961 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 330 / 465
Version history: 7 change(s)
Referenced in: [show references]