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

25
LINES

< > BotCompany Repo | #1019480 - shortJavaTypeDesc

JavaX fragment (include)

sS shortJavaTypeDesc(O o) {
  ret shortJavaTypeDesc(o, 0);
}

sS shortJavaTypeDesc(O o, int safety) {
  if (safety >= 5) ret "...";
  if (o == null) ret "null";
  S name = shortClassName(o);
  if (o cast Collection) {
    if (empty(o)) name += " (empty)";
    else {
      O x = first(o);
      name += "<" + shortJavaTypeDesc(x, safety+1) + ">";
    }
  }
  if (o cast Map) {
    if (empty(o)) name += " (empty)";
    else {
      Pair p = firstKeyAndValue(o);
      name += "<" + shortJavaTypeDesc(pairA(p), safety+1)
        + ", " + shortJavaTypeDesc(pairB(p), safety+1) + ">";
    }
  }
  ret name;
}

download  show line numbers  debug dex   

Travelled to 8 computer(s): cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tvejysmllsmz

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: 67 / 87
Referenced in: [show references]

Formerly at http://tinybrain.de/1019480 & http://1019480.tinybrain.de