1 | static <A> A copyFields(O x, A y, S... fields) { |
2 | if (empty(fields)) { // assume we should copy all fields |
3 | Map<S, O> map = objectToMap(x); |
4 | for (S field : map.keySet()) |
5 | setOpt(y, field, map.get(field)); |
6 | } else |
7 | for (S field : fields) { |
8 | O o = getOpt(x, field); |
9 | if (o != null) |
10 | setOpt(y, field, o); |
11 | } |
12 | ret y; |
13 | } |
14 | |
15 | static <A> A copyFields(O x, A y, Collection<S> fields) { |
16 | ret copyFields(x, y, asStringArray(fields)); |
17 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002178 |
Snippet name: | copyFields - now uses setOpt |
Eternal ID of this version: | #1002178/3 |
Text MD5: | 23380a7f211e585c1880c4122c3c343e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-17 17:14:43 |
Source code size: | 476 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 758 / 1032 |
Version history: | 2 change(s) |
Referenced in: | [show references] |