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

20
LINES

< > BotCompany Repo | #1021464 // collectNonNulls

JavaX fragment (include)

static L collectNonNulls(Collection c, S field) {
  ret collectNonNulls(field, c);
}

static L mapMethodLike collectNonNulls(S field, Collection c) {
  new L l;
  if (c != null) for (O a : c) {
    O x = getOpt(a, field);
    if (x != null) l.add(x);
  }
  ret l;
}

/*ifclass Concept
static L collect(Class c, S field) {
  ret collect(list(c), field);
}
endif
TODO: make translator ignore stuff in ifclass until resolved
*/

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: 239 / 284
Version history: 2 change(s)
Referenced in: [show references]