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

31
LINES

< > BotCompany Repo | #1005264 // renderConcept

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (13300L/91K).

1  
static S renderConcept(Concept.Ref ref) {
2  
  ret renderConcept(ref.get());
3  
}
4  
5  
static S renderConcept(Concept c) {
6  
  if (c == null) ret "null";
7  
  new StringBuilder buf;
8  
  buf.append(c.id + " " + shortDynamicClassName(c));
9  
  for (S field : conceptFields(c)) {
10  
    O val = cget(c, field);
11  
    if (val != null) {
12  
      if (eq(val, Bool.FALSE) && isPrimitiveBoolField(c, field)) continue;
13  
      buf.append(" " + field + "=");
14  
      buf.append(renderConcept_short(c, val));
15  
    }
16  
  }
17  
  ret str(buf);
18  
}
19  
20  
// renders a value in a concept
21  
sS renderConcept_short(Concept c, O val) {
22  
  if (val instanceof Concept)
23  
    ret shortDynamicClassName(val) + ((Concept) val).id;
24  
  else if (val instanceof Concept.RefL)
25  
    ret squareBracket(joinWithComma(lmap(v -> renderConcept_short(c, v), (L) val)));
26  
  else {
27  
    new structure_Data data;
28  
    data.seen.put(c, 0); // for ConceptInList et al
29  
    ret struct(val, data);
30  
  }
31  
}

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, xrpafgyirdlv

No comments. add comment

Snippet ID: #1005264
Snippet name: renderConcept
Eternal ID of this version: #1005264/5
Text MD5: 5c16efbfbf0dd163051640c40b135143
Transpilation MD5: df57a978eb99542d1d459c4055dc7ce5
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-28 13:30:44
Source code size: 937 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 685 / 757
Version history: 4 change(s)
Referenced in: [show references]