1 | // Try to put the structure in multiple lines |
2 | // (works for List and Map) |
3 | // For other values, defaults to structure() |
4 | static S structureLines(O data) {
|
5 | if (data instanceof O[]) data = asList((O[]) data); |
6 | |
7 | if (data instanceof Collection) {
|
8 | new L<S> l; |
9 | for (O x : (Collection) data) |
10 | l.add(structureForUser(x)); |
11 | ret fromLines(l); |
12 | } |
13 | |
14 | ifclass MultiSet |
15 | if (data instanceof MultiSet) data = multiSetToMap(data/MultiSet); |
16 | endif |
17 | |
18 | if (data instanceof Map) {
|
19 | new L<S> l; |
20 | for (O key : ((Map) data).keySet()) {
|
21 | O value = ((Map) data).get(key); |
22 | l.add(structureForUser(key) + " = " + structureForUser(value)); |
23 | } |
24 | ret fromLines(l); |
25 | } |
26 | |
27 | ret structureForUser(data); |
28 | } |
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney
No comments. add comment
| Snippet ID: | #1002415 |
| Snippet name: | structureLines - now calls structureForUser |
| Eternal ID of this version: | #1002415/5 |
| Text MD5: | 4595ee4d9dc642811fef9ec681b33f7d |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-05-20 12:34:33 |
| Source code size: | 747 bytes / 28 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1014 / 1451 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |