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).

static S renderConcept(Concept.Ref ref) {
  ret renderConcept(ref.get());
}

static S renderConcept(Concept c) {
  if (c == null) ret "null";
  new StringBuilder buf;
  buf.append(c.id + " " + shortDynamicClassName(c));
  for (S field : conceptFields(c)) {
    O val = cget(c, field);
    if (val != null) {
      if (eq(val, Bool.FALSE) && isPrimitiveBoolField(c, field)) continue;
      buf.append(" " + field + "=");
      buf.append(renderConcept_short(c, val));
    }
  }
  ret str(buf);
}

// renders a value in a concept
sS renderConcept_short(Concept c, O val) {
  if (val instanceof Concept)
    ret shortDynamicClassName(val) + ((Concept) val).id;
  else if (val instanceof Concept.RefL)
    ret squareBracket(joinWithComma(lmap(v -> renderConcept_short(c, v), (L) val)));
  else {
    new structure_Data data;
    data.seen.put(c, 0); // for ConceptInList et al
    ret struct(val, data);
  }
}

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: 423 / 439
Version history: 4 change(s)
Referenced in: [show references]

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