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

20
LINES

< > BotCompany Repo | #1021464 // collectNonNulls

JavaX fragment (include)

1  
static L collectNonNulls(Collection c, S field) {
2  
  ret collectNonNulls(field, c);
3  
}
4  
5  
static L mapMethodLike collectNonNulls(S field, Collection c) {
6  
  new L l;
7  
  if (c != null) for (O a : c) {
8  
    O x = getOpt(a, field);
9  
    if (x != null) l.add(x);
10  
  }
11  
  ret l;
12  
}
13  
14  
/*ifclass Concept
15  
static L collect(Class c, S field) {
16  
  ret collect(list(c), field);
17  
}
18  
endif
19  
TODO: make translator ignore stuff in ifclass until resolved
20  
*/

Author comment

Began life as a copy of #1003047

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021464
Snippet name: collectNonNulls
Eternal ID of this version: #1021464/3
Text MD5: a94dc8f50b7a8564d597ffc9fb5f5406
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-13 23:06:30
Source code size: 443 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 186 / 226
Version history: 2 change(s)
Referenced in: [show references]