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

15
LINES

< > BotCompany Repo | #1010441 // structureToJava - turn certain kinds of objects into Java code

JavaX fragment (include)

static S structureToJava(O o) {
  if (o == null) ret "null";
  if (o instanceof Bool || o instanceof Number) ret str(o);
  if (o instanceof S) ret quote(o);
  if (o instanceof LinkedHashMap) ret structureToJava_map("litorderedmap", o);
  if (o instanceof HashMap) ret structureToJava_map("litmap", o);
  if (o instanceof TreeMap) ret structureToJava_map("littreemap", o);
  if (o instanceof L)
    ret "ll(" + join(", ", map((L) o, f structureToJava)) + ")";
  fail("boohoo " + className(o));
}

static S structureToJava_map(S type, O o) {
  ret type + "(" + join(", ", mapMapToList((Map) o, func(O a, O b) { structureToJava(a) + ", " + structureToJava(b) })) + ")";
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1010441
Snippet name: structureToJava - turn certain kinds of objects into Java code
Eternal ID of this version: #1010441/8
Text MD5: 5cf2adf540cf5a18d4d489ad1f4f7e7a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-30 14:01:44
Source code size: 682 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 465 / 495
Version history: 7 change(s)
Referenced in: [show references]