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

25
LINES

< > BotCompany Repo | #1019480 // shortJavaTypeDesc

JavaX fragment (include)

1  
sS shortJavaTypeDesc(O o) {
2  
  ret shortJavaTypeDesc(o, 0);
3  
}
4  
5  
sS shortJavaTypeDesc(O o, int safety) {
6  
  if (safety >= 5) ret "...";
7  
  if (o == null) ret "null";
8  
  S name = shortClassName(o);
9  
  if (o cast Collection) {
10  
    if (empty(o)) name += " (empty)";
11  
    else {
12  
      O x = first(o);
13  
      name += "<" + shortJavaTypeDesc(x, safety+1) + ">";
14  
    }
15  
  }
16  
  if (o cast Map) {
17  
    if (empty(o)) name += " (empty)";
18  
    else {
19  
      Pair p = firstKeyAndValue(o);
20  
      name += "<" + shortJavaTypeDesc(pairA(p), safety+1)
21  
        + ", " + shortJavaTypeDesc(pairB(p), safety+1) + ">";
22  
    }
23  
  }
24  
  ret name;
25  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019480
Snippet name: shortJavaTypeDesc
Eternal ID of this version: #1019480/1
Text MD5: 48908a79cade2df7a6836b25bfb526c1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-09 16:07:48
Source code size: 629 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 210 / 254
Referenced in: [show references]