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

27
LINES

< > BotCompany Repo | #1008814 // structureTree

JavaX fragment (include)

// multi-level structureLines
static S structureTree(O data) {
  if (data instanceof O[]) data = asList((O[]) data);
  
  if (data instanceof Collection) {
    new L<S> l;
    l.add(replaceIfEqual(shortClassName(data), "ArrayList", "L"));
    for (O x : (Collection) data)
      l.add(indentx(structureTree(x)));
    ret fromLines(l);
  }
  
  ifclass MultiSet
  if (data instanceof MultiSet) data = multiSetToMap(data/MultiSet);
  endif
  
  if (data instanceof Map) {
    new L<S> l;
    for (O key : ((Map) data).keySet()) {
      O value = ((Map) data).get(key);
      l.add(structureForUser(key) + " = " + structureForUser(value));
    }
    ret fromLines(l);
  }
  
  ret structureForUser(data);
}

Author comment

Began life as a copy of #1002415

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: #1008814
Snippet name: structureTree
Eternal ID of this version: #1008814/2
Text MD5: 3c9491b8d69b2ea6cae4b3ecd5c7744c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-09 03:02:50
Source code size: 729 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 422 / 474
Version history: 1 change(s)
Referenced in: [show references]